mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
chore: Extend linting to .js files.
This commit is contained in:
parent
14023e4c0c
commit
d9f18f813e
@ -1,2 +1,3 @@
|
|||||||
|
coverage
|
||||||
dist
|
dist
|
||||||
node_modules
|
node_modules
|
||||||
|
88
.eslintrc.js
88
.eslintrc.js
@ -2,11 +2,13 @@ module.exports = {
|
|||||||
root: true,
|
root: true,
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
tsconfigRootDir: __dirname, // this is the reason this is a .js file
|
tsconfigRootDir: __dirname,
|
||||||
project: ['./tsconfig.json', './test/tsconfig.json'],
|
project: [ './tsconfig.json', './test/tsconfig.json' ],
|
||||||
},
|
},
|
||||||
globals: {
|
globals: {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
AsyncIterable: 'readonly',
|
AsyncIterable: 'readonly',
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
NodeJS: 'readonly',
|
NodeJS: 'readonly',
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -23,81 +25,105 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
settings: {
|
settings: {
|
||||||
'import/resolver': {
|
'import/resolver': {
|
||||||
'typescript': {
|
typescript: {
|
||||||
'alwaysTryTypes': true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/rdf-js`
|
// Always try to resolve types under `<root>@types` directory
|
||||||
|
// even it doesn't contain any source code, like `@types/rdf-js`
|
||||||
|
alwaysTryTypes: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/consistent-type-definitions': 'off', // there are valid typing reasons to have one or the other
|
// There are valid typing reasons to have one or the other
|
||||||
|
'@typescript-eslint/consistent-type-definitions': 'off',
|
||||||
'@typescript-eslint/lines-between-class-members': [ 'error', { exceptAfterSingleLine: true }],
|
'@typescript-eslint/lines-between-class-members': [ 'error', { exceptAfterSingleLine: true }],
|
||||||
'@typescript-eslint/no-empty-interface': 'off',
|
'@typescript-eslint/no-empty-interface': 'off',
|
||||||
'@typescript-eslint/no-invalid-void-type': 'off', // breaks with default void in Asynchandler 2nd generic
|
// Breaks with default void in AsyncHandler 2nd generic
|
||||||
'@typescript-eslint/no-unnecessary-condition': 'off', // problems with optional parameters
|
'@typescript-eslint/no-invalid-void-type': 'off',
|
||||||
|
// Problems with optional parameters
|
||||||
|
'@typescript-eslint/no-unnecessary-condition': 'off',
|
||||||
'@typescript-eslint/space-before-function-paren': [ 'error', 'never' ],
|
'@typescript-eslint/space-before-function-paren': [ 'error', 'never' ],
|
||||||
'@typescript-eslint/unbound-method': 'off',
|
'@typescript-eslint/unbound-method': 'off',
|
||||||
'@typescript-eslint/unified-signatures': 'off',
|
'@typescript-eslint/unified-signatures': 'off',
|
||||||
'class-methods-use-this': 'off', // conflicts with functions from interfaces that sometimes don't require `this`
|
// Conflicts with functions from interfaces that sometimes don't require `this`
|
||||||
'comma-dangle': ['error', 'always-multiline'],
|
'class-methods-use-this': 'off',
|
||||||
'dot-location': ['error', 'property'],
|
'comma-dangle': [ 'error', 'always-multiline' ],
|
||||||
'generator-star-spacing': ['error', 'after'],
|
'dot-location': [ 'error', 'property' ],
|
||||||
'lines-around-comment': 'off', // conflicts with padded-blocks
|
'generator-star-spacing': [ 'error', 'after' ],
|
||||||
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
// Conflicts with padded-blocks
|
||||||
'max-len': ['error', { code: 120, ignoreUrls: true }],
|
'lines-around-comment': 'off',
|
||||||
'new-cap': 'off', // used for RDF constants
|
'lines-between-class-members': [ 'error', 'always', { exceptAfterSingleLine: true }],
|
||||||
'no-param-reassign': 'off', // necessary in constructor overloading
|
'max-len': [ 'error', { code: 120, ignoreUrls: true }],
|
||||||
'no-underscore-dangle': 'off', // conflicts with external libraries
|
// Used for RDF constants
|
||||||
'no-unused-vars': 'off', // already checked by @typescript-eslint/no-unused-vars
|
'new-cap': 'off',
|
||||||
|
// Necessary in constructor overloading
|
||||||
|
'no-param-reassign': 'off',
|
||||||
|
// Conflicts with external libraries
|
||||||
|
'no-underscore-dangle': 'off',
|
||||||
|
// Already checked by @typescript-eslint/no-unused-vars
|
||||||
|
'no-unused-vars': 'off',
|
||||||
'padding-line-between-statements': 'off',
|
'padding-line-between-statements': 'off',
|
||||||
'prefer-named-capture-group': 'off',
|
'prefer-named-capture-group': 'off',
|
||||||
|
// Already generated by TypeScript
|
||||||
|
strict: 'off',
|
||||||
'tsdoc/syntax': 'error',
|
'tsdoc/syntax': 'error',
|
||||||
'unicorn/catch-error-name': 'off',
|
'unicorn/catch-error-name': 'off',
|
||||||
'unicorn/import-index': 'off',
|
'unicorn/import-index': 'off',
|
||||||
'unicorn/import-style': 'off',
|
'unicorn/import-style': 'off',
|
||||||
'unicorn/no-fn-reference-in-iterator': 'off', // this prevents some functional programming paradigms
|
// This prevents some functional programming paradigms
|
||||||
|
'unicorn/no-fn-reference-in-iterator': 'off',
|
||||||
'unicorn/no-object-as-default-parameter': 'off',
|
'unicorn/no-object-as-default-parameter': 'off',
|
||||||
'unicorn/numeric-separators-style': 'off',
|
'unicorn/numeric-separators-style': 'off',
|
||||||
'unicorn/prefer-ternary': 'off', // can get ugly with large single statements
|
// Can get ugly with large single statements
|
||||||
'yield-star-spacing': ['error', 'after'],
|
'unicorn/prefer-ternary': 'off',
|
||||||
|
'yield-star-spacing': [ 'error', 'after' ],
|
||||||
|
|
||||||
// Naming conventions
|
// Naming conventions
|
||||||
'@typescript-eslint/naming-convention': [
|
'@typescript-eslint/naming-convention': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
selector: 'default',
|
selector: 'default',
|
||||||
format: ['camelCase'],
|
format: [ 'camelCase' ],
|
||||||
leadingUnderscore: 'forbid',
|
leadingUnderscore: 'forbid',
|
||||||
trailingUnderscore: 'forbid',
|
trailingUnderscore: 'forbid',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: 'variable',
|
selector: 'variable',
|
||||||
format: ['camelCase', 'UPPER_CASE'],
|
format: [ 'camelCase', 'UPPER_CASE' ],
|
||||||
leadingUnderscore: 'forbid',
|
leadingUnderscore: 'forbid',
|
||||||
trailingUnderscore: 'forbid',
|
trailingUnderscore: 'forbid',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: 'typeLike',
|
selector: 'typeLike',
|
||||||
format: ['PascalCase'],
|
format: [ 'PascalCase' ],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: [ 'typeParameter' ],
|
selector: [ 'typeParameter' ],
|
||||||
format: [ 'PascalCase' ],
|
format: [ 'PascalCase' ],
|
||||||
prefix: [ 'T' ],
|
prefix: [ 'T' ],
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
// Import
|
// Import
|
||||||
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
|
'@typescript-eslint/consistent-type-imports': [ 'error', { prefer: 'type-imports' }],
|
||||||
'sort-imports': 'off', // Disabled in favor of eslint-plugin-import
|
// Disabled in favor of eslint-plugin-import
|
||||||
'import/order': ['error', {
|
'sort-imports': 'off',
|
||||||
|
'import/order': [ 'error', {
|
||||||
alphabetize: {
|
alphabetize: {
|
||||||
order: 'asc',
|
order: 'asc',
|
||||||
caseInsensitive: true,
|
caseInsensitive: true,
|
||||||
}
|
},
|
||||||
}],
|
}],
|
||||||
'import/no-duplicates': 'error',
|
'import/no-duplicates': 'error',
|
||||||
'import/no-extraneous-dependencies': 'error',
|
'import/no-extraneous-dependencies': 'error',
|
||||||
'no-duplicate-imports': 'off', // doesn't work with type imports
|
// Doesn't work with type imports
|
||||||
|
'no-duplicate-imports': 'off',
|
||||||
'unused-imports/no-unused-imports-ts': 'error',
|
'unused-imports/no-unused-imports-ts': 'error',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: '*.js',
|
||||||
|
parser: 'espree',
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const { runCli } = require("..");
|
const { runCli } = require('..');
|
||||||
runCli();
|
runCli();
|
||||||
|
@ -1,32 +1,33 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"globals": {
|
globals: {
|
||||||
"ts-jest": {
|
'ts-jest': {
|
||||||
"tsconfig": "tsconfig.json"
|
tsconfig: 'tsconfig.json',
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"transform": {
|
|
||||||
"^.+\\.ts$": "ts-jest"
|
|
||||||
},
|
},
|
||||||
"testRegex": "/test/(unit|integration)/.*\\.test\\.ts$",
|
transform: {
|
||||||
"moduleFileExtensions": [
|
'^.+\\.ts$': 'ts-jest',
|
||||||
"ts",
|
},
|
||||||
"js"
|
testRegex: '/test/(unit|integration)/.*\\.test\\.ts$',
|
||||||
|
moduleFileExtensions: [
|
||||||
|
'ts',
|
||||||
|
'js',
|
||||||
],
|
],
|
||||||
"testEnvironment": "node",
|
testEnvironment: 'node',
|
||||||
"setupFilesAfterEnv": ["jest-rdf", "<rootDir>/test/util/SetupTests.ts"],
|
setupFilesAfterEnv: [ 'jest-rdf', '<rootDir>/test/util/SetupTests.ts' ],
|
||||||
"collectCoverage": true,
|
collectCoverage: true,
|
||||||
"coveragePathIgnorePatterns": [
|
coveragePathIgnorePatterns: [
|
||||||
"/dist/",
|
'/dist/',
|
||||||
"/node_modules/",
|
'/node_modules/',
|
||||||
"/test/"
|
'/test/',
|
||||||
],
|
],
|
||||||
"coverageThreshold": {
|
coverageThreshold: {
|
||||||
"./src": {
|
'./src': {
|
||||||
"branches": 100,
|
branches: 100,
|
||||||
"functions": 100,
|
functions: 100,
|
||||||
"lines": 100,
|
lines: 100,
|
||||||
"statements": 100
|
statements: 100,
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"testTimeout": 10000, // Slower machines had problems calling the WebSocket integration callbacks on time
|
},
|
||||||
|
// Slower machines had problems calling the WebSocket integration callbacks on time
|
||||||
|
testTimeout: 10000,
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
"docker:start": "./test/docker/docker-start.sh",
|
"docker:start": "./test/docker/docker-start.sh",
|
||||||
"docker:stop": "./test/docker/docker-stop.sh",
|
"docker:stop": "./test/docker/docker-stop.sh",
|
||||||
"jest": "jest",
|
"jest": "jest",
|
||||||
"lint": "eslint . --ext .ts --cache",
|
"lint": "eslint . --cache",
|
||||||
"prepare": "npm run build",
|
"prepare": "npm run build",
|
||||||
"start": "node ./bin/server.js -p 3000",
|
"start": "node ./bin/server.js -p 3000",
|
||||||
"test": "npm run test:tsc && npm run jest",
|
"test": "npm run test:tsc && npm run jest",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user