@jeroenpol/eslint-config 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.eslintrc.json +24 -0
- package/config/best-practices.js +118 -0
- package/config/code-style.js +163 -0
- package/config/imports.js +32 -0
- package/index.js +1 -0
- package/package.json +71 -0
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": ["@typescript-eslint", "functional"],
|
|
5
|
+
"overrides": [
|
|
6
|
+
{
|
|
7
|
+
"files": ["*.ts", "*.tsx"],
|
|
8
|
+
"parser": "@typescript-eslint/parser",
|
|
9
|
+
"extends": [
|
|
10
|
+
"eslint:recommended",
|
|
11
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
12
|
+
"plugin:@typescript-eslint/recommended",
|
|
13
|
+
"prettier",
|
|
14
|
+
"./config/best-practices.js",
|
|
15
|
+
"./config/code-style.js",
|
|
16
|
+
"./config/imports.js"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"no-unused-vars": "off"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"ignorePatterns": ["graphql.ts"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
overrides: [
|
|
3
|
+
{
|
|
4
|
+
files: ['*.ts', '*.tsx'],
|
|
5
|
+
parser: '@typescript-eslint/parser',
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaVersion: 2020,
|
|
8
|
+
sourceType: 'module',
|
|
9
|
+
project: './tsconfig.*json',
|
|
10
|
+
},
|
|
11
|
+
plugins: ['@typescript-eslint', 'rxjs-angular', 'sonarjs'],
|
|
12
|
+
rules: {
|
|
13
|
+
// Code complexity rules
|
|
14
|
+
'max-depth': ['error', 3], // Goal value: 2
|
|
15
|
+
'max-nested-callbacks': ['error', 5], // Goal value: 2-3
|
|
16
|
+
"max-statements-per-line": ['error', { "max": 1 }],
|
|
17
|
+
'complexity': ['error', { max: 8 }], // GOAL VALUE: 7
|
|
18
|
+
'sonarjs/cognitive-complexity': ['error', 10], // GOAL VALUE: 6
|
|
19
|
+
|
|
20
|
+
// Prevent code smells
|
|
21
|
+
'max-lines-per-function': ['error', {'max': 60, 'skipBlankLines': true, 'skipComments': true}], // Goal value: 40
|
|
22
|
+
'max-statements': ['error', 20], // Goal value: 16-18?
|
|
23
|
+
'sonarjs/max-switch-cases': ['error', 10],
|
|
24
|
+
'sonarjs/no-nested-switch': 'error',
|
|
25
|
+
|
|
26
|
+
// Prevent accidental bugs
|
|
27
|
+
'no-param-reassign': 'error',
|
|
28
|
+
'no-unreachable': 'error',
|
|
29
|
+
'no-multi-assign': 'error',
|
|
30
|
+
'array-callback-return': 'error',
|
|
31
|
+
'sonarjs/no-extra-arguments': 'error',
|
|
32
|
+
'sonarjs/non-existent-operator': 'error',
|
|
33
|
+
'sonarjs/no-inverted-boolean-check': 'error',
|
|
34
|
+
'eqeqeq': 'error',
|
|
35
|
+
'default-case': 'error',
|
|
36
|
+
'no-fallthrough': 'error',
|
|
37
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
38
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
39
|
+
|
|
40
|
+
// Type safety
|
|
41
|
+
'@typescript-eslint/no-explicit-any': 'warn', // TODO: set to error
|
|
42
|
+
'@typescript-eslint/explicit-function-return-type': ['error', { allowHigherOrderFunctions: true }],
|
|
43
|
+
|
|
44
|
+
// Disable JS features
|
|
45
|
+
'no-debugger': 'error',
|
|
46
|
+
'no-console': 'error',
|
|
47
|
+
|
|
48
|
+
// Disabled ESLint rules
|
|
49
|
+
'@typescript-eslint/array-type': 'off',
|
|
50
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
51
|
+
'max-classes-per-file': 'off',
|
|
52
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
53
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
54
|
+
'sort-keys': 'off',
|
|
55
|
+
'no-empty': 'off',
|
|
56
|
+
'no-shadow': 'off',
|
|
57
|
+
|
|
58
|
+
// Conventions
|
|
59
|
+
'no-array-constructor': 'error',
|
|
60
|
+
'quote-props': ['warn', 'as-needed'],
|
|
61
|
+
'@typescript-eslint/ban-types': [
|
|
62
|
+
'error',
|
|
63
|
+
{
|
|
64
|
+
extendDefaults: false,
|
|
65
|
+
types: {
|
|
66
|
+
Boolean: {
|
|
67
|
+
message: 'Use boolean instead',
|
|
68
|
+
fixWith: 'boolean',
|
|
69
|
+
},
|
|
70
|
+
Number: {
|
|
71
|
+
message: 'Use number instead',
|
|
72
|
+
fixWith: 'number',
|
|
73
|
+
},
|
|
74
|
+
String: {
|
|
75
|
+
message: 'Use string instead',
|
|
76
|
+
fixWith: 'string',
|
|
77
|
+
},
|
|
78
|
+
Symbol: {
|
|
79
|
+
message: 'Use symbol instead',
|
|
80
|
+
fixWith: 'symbol',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
'@typescript-eslint/naming-convention': [
|
|
86
|
+
'warn',
|
|
87
|
+
{
|
|
88
|
+
selector: 'enum',
|
|
89
|
+
format: ['PascalCase', 'UPPER_CASE'],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
selector: 'interface',
|
|
93
|
+
format: ['PascalCase'],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
'no-restricted-syntax': [
|
|
97
|
+
'error',
|
|
98
|
+
{
|
|
99
|
+
selector:
|
|
100
|
+
"CallExpression[callee.object.name='console'][callee.property.name=/^(debug|info|time|timeEnd|trace)$/]",
|
|
101
|
+
message: 'Unexpected property on console object was called',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
|
|
105
|
+
// Performance improvements + preventing memory leaks
|
|
106
|
+
"rxjs-angular/prefer-takeuntil": [
|
|
107
|
+
"error",
|
|
108
|
+
{
|
|
109
|
+
"alias": ["untilDestroyed"],
|
|
110
|
+
"checkComplete": true,
|
|
111
|
+
"checkDecorators": ["Component"],
|
|
112
|
+
"checkDestroy": true
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'@typescript-eslint/explicit-member-accessibility': 'off',
|
|
4
|
+
},
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
files: ['*.ts', '*.tsx'],
|
|
8
|
+
parser: '@typescript-eslint/parser',
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2020,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
project: './tsconfig.*json',
|
|
13
|
+
},
|
|
14
|
+
plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'],
|
|
15
|
+
rules: {
|
|
16
|
+
'array-bracket-newline': ['warn', 'consistent'],
|
|
17
|
+
'array-bracket-spacing': ['warn', 'never'],
|
|
18
|
+
'array-element-newline': ['warn', 'consistent'],
|
|
19
|
+
'arrow-parens': 'warn', // overwritten NG default
|
|
20
|
+
'arrow-spacing': 'warn',
|
|
21
|
+
'block-spacing': 'warn',
|
|
22
|
+
'brace-style': 'warn',
|
|
23
|
+
'comma-dangle': [
|
|
24
|
+
'warn',
|
|
25
|
+
{
|
|
26
|
+
arrays: 'always-multiline',
|
|
27
|
+
objects: 'always-multiline',
|
|
28
|
+
imports: 'always-multiline',
|
|
29
|
+
exports: 'never',
|
|
30
|
+
functions: 'never',
|
|
31
|
+
},
|
|
32
|
+
], // overwritten NG default
|
|
33
|
+
'comma-spacing': 'warn',
|
|
34
|
+
'computed-property-spacing': 'warn',
|
|
35
|
+
curly: ['warn', 'all'],
|
|
36
|
+
'dot-location': ['warn', 'property'],
|
|
37
|
+
'eol-last': 'warn',
|
|
38
|
+
'func-call-spacing': 'warn',
|
|
39
|
+
'function-call-argument-newline': ['warn', 'consistent'],
|
|
40
|
+
'function-paren-newline': ['warn', 'multiline-arguments'],
|
|
41
|
+
'generator-star-spacing': 'off',
|
|
42
|
+
'implicit-arrow-linebreak': 'off',
|
|
43
|
+
indent: 'off',
|
|
44
|
+
'@typescript-eslint/indent': [
|
|
45
|
+
'warn',
|
|
46
|
+
2,
|
|
47
|
+
{
|
|
48
|
+
SwitchCase: 1,
|
|
49
|
+
ObjectExpression: 1,
|
|
50
|
+
offsetTernaryExpressions: true,
|
|
51
|
+
ImportDeclaration: 'first',
|
|
52
|
+
FunctionDeclaration: { parameters: 'first', body: 1 },
|
|
53
|
+
CallExpression: { arguments: 'first' },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
'key-spacing': ['warn'],
|
|
57
|
+
|
|
58
|
+
'keyword-spacing': 'off', // overridden by @typescript-eslint
|
|
59
|
+
'@typescript-eslint/keyword-spacing': ['warn', { after: true, before: true }],
|
|
60
|
+
|
|
61
|
+
'linebreak-style': 'off',
|
|
62
|
+
'max-len': [
|
|
63
|
+
'error',
|
|
64
|
+
{
|
|
65
|
+
code: 160,
|
|
66
|
+
ignoreRegExpLiterals: true,
|
|
67
|
+
ignoreStrings: true,
|
|
68
|
+
ignoreTemplateLiterals: true,
|
|
69
|
+
ignoreUrls: true,
|
|
70
|
+
},
|
|
71
|
+
], // overwritten NG default
|
|
72
|
+
'@typescript-eslint/member-delimiter-style': ['warn'],
|
|
73
|
+
'multiline-ternary': ['warn', 'always'],
|
|
74
|
+
'new-parens': 'warn',
|
|
75
|
+
'newline-per-chained-call': 'off',
|
|
76
|
+
'no-confusing-arrow': ['error'],
|
|
77
|
+
'no-constant-condition': 'off',
|
|
78
|
+
'no-extra-parens': 'off', // prettier is actually very liberate with parens, so disabled the rule
|
|
79
|
+
'no-extra-semi': 'warn',
|
|
80
|
+
'no-floating-decimal': 'off',
|
|
81
|
+
'no-mixed-operators': ['error'],
|
|
82
|
+
'no-mixed-spaces-and-tabs': 'error',
|
|
83
|
+
'no-multi-spaces': 'error',
|
|
84
|
+
'no-multiple-empty-lines': ['warn', { max: 1 }], // overwritten NG default
|
|
85
|
+
'no-tabs': 'error',
|
|
86
|
+
'no-trailing-spaces': 'warn',
|
|
87
|
+
'no-unexpected-multiline': 'error',
|
|
88
|
+
|
|
89
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
90
|
+
"unused-imports/no-unused-imports": "error",
|
|
91
|
+
"unused-imports/no-unused-vars": [
|
|
92
|
+
"warn",
|
|
93
|
+
{ "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
|
|
94
|
+
],
|
|
95
|
+
'no-duplicate-imports': 'warn',
|
|
96
|
+
|
|
97
|
+
'no-useless-constructor': 'off', // overridden by @typescript-eslint
|
|
98
|
+
'@typescript-eslint/no-useless-constructor': ['error'],
|
|
99
|
+
|
|
100
|
+
'no-whitespace-before-property': 'warn',
|
|
101
|
+
'nonblock-statement-body-position': 'warn',
|
|
102
|
+
'object-curly-newline': ['error', { consistent: true }],
|
|
103
|
+
'object-curly-spacing': ['warn', 'always'],
|
|
104
|
+
'object-property-newline': ['warn', { allowAllPropertiesOnSameLine: true }],
|
|
105
|
+
'one-var-declaration-per-line': 'warn',
|
|
106
|
+
'operator-linebreak': ['warn', 'after', { overrides: { '?': 'before', ':': 'before' } }],
|
|
107
|
+
'padded-blocks': ['warn', { blocks: 'never', switches: 'never' }],
|
|
108
|
+
'prefer-arrow-callback': 'warn',
|
|
109
|
+
|
|
110
|
+
'prefer-includes': 'off', // overruled by @typescript-eslint
|
|
111
|
+
'@typescript-eslint/prefer-includes': 'warn',
|
|
112
|
+
|
|
113
|
+
'prefer-optional-chain': 'off', // overruled by @typescript-eslint
|
|
114
|
+
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
115
|
+
|
|
116
|
+
quotes: ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }], // overwritten NG default
|
|
117
|
+
'rest-spread-spacing': ['error', 'never'],
|
|
118
|
+
semi: ['warn', 'always'],
|
|
119
|
+
'semi-spacing': 'error',
|
|
120
|
+
'semi-style': 'warn',
|
|
121
|
+
'space-before-blocks': 'warn',
|
|
122
|
+
'space-before-function-paren': ['warn', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
|
|
123
|
+
'space-in-parens': 'warn',
|
|
124
|
+
'space-infix-ops': 'warn',
|
|
125
|
+
'space-unary-ops': 'warn',
|
|
126
|
+
'switch-colon-spacing': 'warn',
|
|
127
|
+
'template-curly-spacing': 'warn',
|
|
128
|
+
'unicode-bom': 'warn',
|
|
129
|
+
'wrap-iife': 'warn',
|
|
130
|
+
'wrap-regex': 'off',
|
|
131
|
+
'yield-star-spacing': 'error',
|
|
132
|
+
'no-unused-expressions': 'error',
|
|
133
|
+
'prefer-const': 'error',
|
|
134
|
+
'id-length': ['error', { 'min': 2, 'properties': 'never', 'exceptions': ['i', 'e', 'a', 'b', '_'] }], // TODO: remove some of these exceptions
|
|
135
|
+
'@typescript-eslint/no-parameter-properties': 'off',
|
|
136
|
+
'@typescript-eslint/member-ordering': ['warn'],
|
|
137
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
138
|
+
'error',
|
|
139
|
+
{
|
|
140
|
+
accessibility: 'off',
|
|
141
|
+
overrides: {
|
|
142
|
+
accessors: 'explicit',
|
|
143
|
+
constructors: 'no-public',
|
|
144
|
+
methods: 'explicit',
|
|
145
|
+
properties: 'explicit',
|
|
146
|
+
parameterProperties: 'explicit',
|
|
147
|
+
},
|
|
148
|
+
ignoredMethodNames: [
|
|
149
|
+
'ngOnChanges',
|
|
150
|
+
'ngOnInit',
|
|
151
|
+
'ngDoCheck',
|
|
152
|
+
'ngAfterContentInit',
|
|
153
|
+
'ngAfterContentChecked',
|
|
154
|
+
'ngAfterViewInit',
|
|
155
|
+
'ngAfterViewChecked',
|
|
156
|
+
'ngOnDestroy',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
overrides: [
|
|
3
|
+
{
|
|
4
|
+
files: ['*.ts'],
|
|
5
|
+
parser: '@typescript-eslint/parser',
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaVersion: 2020,
|
|
8
|
+
sourceType: 'module',
|
|
9
|
+
project: './tsconfig.*json',
|
|
10
|
+
},
|
|
11
|
+
plugins: ['@typescript-eslint', 'simple-import-sort'],
|
|
12
|
+
rules: {
|
|
13
|
+
/* https://github.com/lydell/eslint-plugin-simple-import-sort#usage */
|
|
14
|
+
'simple-import-sort/imports': 'error',
|
|
15
|
+
'simple-import-sort/exports': 'error',
|
|
16
|
+
'sort-imports': 'off',
|
|
17
|
+
'import/order': 'off',
|
|
18
|
+
'no-restricted-imports': [
|
|
19
|
+
'error',
|
|
20
|
+
{
|
|
21
|
+
paths: [
|
|
22
|
+
{
|
|
23
|
+
name: 'rxjs/Rx',
|
|
24
|
+
message: "Please import directly from 'rxjs' instead",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./.eslintrc.json')
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jeroenpol/eslint-config",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "eslint-config as configured by Jeroen Pol",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/jeroenpol/eslint-config.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"JavaScript Standard Style",
|
|
15
|
+
"check",
|
|
16
|
+
"checker",
|
|
17
|
+
"code",
|
|
18
|
+
"code checker",
|
|
19
|
+
"code linter",
|
|
20
|
+
"code standards",
|
|
21
|
+
"code style",
|
|
22
|
+
"enforce",
|
|
23
|
+
"eslint",
|
|
24
|
+
"eslintconfig",
|
|
25
|
+
"hint",
|
|
26
|
+
"jscs",
|
|
27
|
+
"jshint",
|
|
28
|
+
"lint",
|
|
29
|
+
"eslint",
|
|
30
|
+
"es-lint",
|
|
31
|
+
"policy",
|
|
32
|
+
"quality",
|
|
33
|
+
"simple",
|
|
34
|
+
"standard",
|
|
35
|
+
"standard style",
|
|
36
|
+
"style",
|
|
37
|
+
"style checker",
|
|
38
|
+
"style linter",
|
|
39
|
+
"verify",
|
|
40
|
+
"TypeScript"
|
|
41
|
+
],
|
|
42
|
+
"author": "Jeroen Pol",
|
|
43
|
+
"license": "ISC",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/jeroenpol/eslint-config/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/jeroenpol/eslint-config#readme",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@typescript-eslint/parser": "^5.43.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
|
53
|
+
"eslint": "^8.0.1",
|
|
54
|
+
"eslint-plugin-import": "^2.25.2",
|
|
55
|
+
"eslint-plugin-n": "^15.0.0",
|
|
56
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
57
|
+
"typescript": "*"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
61
|
+
"@typescript-eslint/parser": "^5.57.1",
|
|
62
|
+
"eslint": "^8.38.0",
|
|
63
|
+
"eslint-config-prettier": "^8.8.0",
|
|
64
|
+
"eslint-plugin-functional": "^5.0.7",
|
|
65
|
+
"eslint-plugin-rxjs-angular": "^2.0.0",
|
|
66
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
67
|
+
"eslint-plugin-sonarjs": "^0.19.0",
|
|
68
|
+
"eslint-plugin-unused-imports": "^2.0.0",
|
|
69
|
+
"typescript": "^5.0.4"
|
|
70
|
+
}
|
|
71
|
+
}
|