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
|
||||
node_modules
|
||||
|
90
.eslintrc.js
90
.eslintrc.js
@ -2,11 +2,13 @@ module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname, // this is the reason this is a .js file
|
||||
project: ['./tsconfig.json', './test/tsconfig.json'],
|
||||
tsconfigRootDir: __dirname,
|
||||
project: [ './tsconfig.json', './test/tsconfig.json' ],
|
||||
},
|
||||
globals: {
|
||||
globals: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
AsyncIterable: 'readonly',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
NodeJS: 'readonly',
|
||||
},
|
||||
plugins: [
|
||||
@ -23,81 +25,105 @@ module.exports = {
|
||||
],
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
'typescript': {
|
||||
'alwaysTryTypes': true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/rdf-js`
|
||||
typescript: {
|
||||
// Always try to resolve types under `<root>@types` directory
|
||||
// even it doesn't contain any source code, like `@types/rdf-js`
|
||||
alwaysTryTypes: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
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/no-empty-interface': 'off',
|
||||
'@typescript-eslint/no-invalid-void-type': 'off', // breaks with default void in Asynchandler 2nd generic
|
||||
'@typescript-eslint/no-unnecessary-condition': 'off', // problems with optional parameters
|
||||
// Breaks with default void in AsyncHandler 2nd generic
|
||||
'@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/unbound-method': 'off',
|
||||
'@typescript-eslint/unified-signatures': 'off',
|
||||
'class-methods-use-this': 'off', // conflicts with functions from interfaces that sometimes don't require `this`
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'dot-location': ['error', 'property'],
|
||||
'generator-star-spacing': ['error', 'after'],
|
||||
'lines-around-comment': 'off', // conflicts with padded-blocks
|
||||
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
||||
'max-len': ['error', { code: 120, ignoreUrls: true }],
|
||||
'new-cap': 'off', // used for RDF constants
|
||||
'no-param-reassign': 'off', // necessary in constructor overloading
|
||||
'no-underscore-dangle': 'off', // conflicts with external libraries
|
||||
'no-unused-vars': 'off', // already checked by @typescript-eslint/no-unused-vars
|
||||
// Conflicts with functions from interfaces that sometimes don't require `this`
|
||||
'class-methods-use-this': 'off',
|
||||
'comma-dangle': [ 'error', 'always-multiline' ],
|
||||
'dot-location': [ 'error', 'property' ],
|
||||
'generator-star-spacing': [ 'error', 'after' ],
|
||||
// Conflicts with padded-blocks
|
||||
'lines-around-comment': 'off',
|
||||
'lines-between-class-members': [ 'error', 'always', { exceptAfterSingleLine: true }],
|
||||
'max-len': [ 'error', { code: 120, ignoreUrls: true }],
|
||||
// Used for RDF constants
|
||||
'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',
|
||||
'prefer-named-capture-group': 'off',
|
||||
// Already generated by TypeScript
|
||||
strict: 'off',
|
||||
'tsdoc/syntax': 'error',
|
||||
'unicorn/catch-error-name': 'off',
|
||||
'unicorn/import-index': '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/numeric-separators-style': 'off',
|
||||
'unicorn/prefer-ternary': 'off', // can get ugly with large single statements
|
||||
'yield-star-spacing': ['error', 'after'],
|
||||
// Can get ugly with large single statements
|
||||
'unicorn/prefer-ternary': 'off',
|
||||
'yield-star-spacing': [ 'error', 'after' ],
|
||||
|
||||
// Naming conventions
|
||||
'@typescript-eslint/naming-convention': [
|
||||
'error',
|
||||
{
|
||||
selector: 'default',
|
||||
format: ['camelCase'],
|
||||
format: [ 'camelCase' ],
|
||||
leadingUnderscore: 'forbid',
|
||||
trailingUnderscore: 'forbid',
|
||||
},
|
||||
{
|
||||
selector: 'variable',
|
||||
format: ['camelCase', 'UPPER_CASE'],
|
||||
format: [ 'camelCase', 'UPPER_CASE' ],
|
||||
leadingUnderscore: 'forbid',
|
||||
trailingUnderscore: 'forbid',
|
||||
},
|
||||
{
|
||||
selector: 'typeLike',
|
||||
format: ['PascalCase'],
|
||||
format: [ 'PascalCase' ],
|
||||
},
|
||||
{
|
||||
selector: [ 'typeParameter' ],
|
||||
format: [ 'PascalCase' ],
|
||||
prefix: [ 'T' ],
|
||||
}
|
||||
},
|
||||
],
|
||||
|
||||
// Import
|
||||
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
|
||||
'sort-imports': 'off', // Disabled in favor of eslint-plugin-import
|
||||
'import/order': ['error', {
|
||||
'@typescript-eslint/consistent-type-imports': [ 'error', { prefer: 'type-imports' }],
|
||||
// Disabled in favor of eslint-plugin-import
|
||||
'sort-imports': 'off',
|
||||
'import/order': [ 'error', {
|
||||
alphabetize: {
|
||||
order: 'asc',
|
||||
caseInsensitive: true,
|
||||
}
|
||||
},
|
||||
}],
|
||||
'import/no-duplicates': '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',
|
||||
},
|
||||
|
||||
overrides: [
|
||||
{
|
||||
files: '*.js',
|
||||
parser: 'espree',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
const { runCli } = require("..");
|
||||
const { runCli } = require('..');
|
||||
runCli();
|
||||
|
@ -1,32 +1,33 @@
|
||||
module.exports = {
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"tsconfig": "tsconfig.json"
|
||||
}
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsconfig: 'tsconfig.json',
|
||||
},
|
||||
},
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
"testRegex": "/test/(unit|integration)/.*\\.test\\.ts$",
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"js"
|
||||
testRegex: '/test/(unit|integration)/.*\\.test\\.ts$',
|
||||
moduleFileExtensions: [
|
||||
'ts',
|
||||
'js',
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"setupFilesAfterEnv": ["jest-rdf", "<rootDir>/test/util/SetupTests.ts"],
|
||||
"collectCoverage": true,
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/dist/",
|
||||
"/node_modules/",
|
||||
"/test/"
|
||||
testEnvironment: 'node',
|
||||
setupFilesAfterEnv: [ 'jest-rdf', '<rootDir>/test/util/SetupTests.ts' ],
|
||||
collectCoverage: true,
|
||||
coveragePathIgnorePatterns: [
|
||||
'/dist/',
|
||||
'/node_modules/',
|
||||
'/test/',
|
||||
],
|
||||
"coverageThreshold": {
|
||||
"./src": {
|
||||
"branches": 100,
|
||||
"functions": 100,
|
||||
"lines": 100,
|
||||
"statements": 100
|
||||
}
|
||||
coverageThreshold: {
|
||||
'./src': {
|
||||
branches: 100,
|
||||
functions: 100,
|
||||
lines: 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:stop": "./test/docker/docker-stop.sh",
|
||||
"jest": "jest",
|
||||
"lint": "eslint . --ext .ts --cache",
|
||||
"lint": "eslint . --cache",
|
||||
"prepare": "npm run build",
|
||||
"start": "node ./bin/server.js -p 3000",
|
||||
"test": "npm run test:tsc && npm run jest",
|
||||
|
Loading…
x
Reference in New Issue
Block a user