@jeroenpol/eslint-config 1.0.1 → 1.0.3
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/.eslintrc +0 -1
- package/configuration/best-practices.js +20 -24
- package/configuration/code-style.js +17 -19
- package/configuration/imports.js +1 -1
- package/index.js +1 -0
- package/package.json +15 -3
- package/tsconfig.json +18 -0
package/.eslintrc
CHANGED
|
@@ -3,28 +3,24 @@ module.exports = {
|
|
|
3
3
|
{
|
|
4
4
|
files: ['*.ts', '*.tsx'],
|
|
5
5
|
parser: '@typescript-eslint/parser',
|
|
6
|
-
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaVersion: 2020,
|
|
8
|
+
sourceType: 'module',
|
|
9
|
+
},
|
|
10
|
+
plugins: ['@typescript-eslint', 'rxjs-angular', 'sonarjs'],
|
|
7
11
|
rules: {
|
|
8
12
|
// Code complexity rules
|
|
9
|
-
'max-depth': ['error',
|
|
10
|
-
'max-nested-callbacks': ['error',
|
|
11
|
-
|
|
12
|
-
complexity: ['error', { max:
|
|
13
|
-
'sonarjs/cognitive-complexity': ['error',
|
|
13
|
+
'max-depth': ['error', 8], // Goal value: 2
|
|
14
|
+
'max-nested-callbacks': ['error', 8], // Goal value: 2-3
|
|
15
|
+
"max-statements-per-line": ['error', { "max": 1 }],
|
|
16
|
+
'complexity': ['error', { max: 15 }], // GOAL VALUE: 7
|
|
17
|
+
'sonarjs/cognitive-complexity': ['error', 15], // GOAL VALUE: 6
|
|
14
18
|
|
|
15
19
|
// Prevent code smells
|
|
16
|
-
'max-lines-per-function': ['error', { max: 60, skipBlankLines: true, skipComments: true }], // Goal value: 40
|
|
20
|
+
'max-lines-per-function': ['error', { 'max': 60, 'skipBlankLines': true, 'skipComments': true }], // Goal value: 40
|
|
17
21
|
'max-statements': ['error', 20], // Goal value: 16-18?
|
|
18
22
|
'sonarjs/max-switch-cases': ['error', 10],
|
|
19
23
|
'sonarjs/no-nested-switch': 'error',
|
|
20
|
-
'default-case-last': 'error',
|
|
21
|
-
'default-param-last': 'error',
|
|
22
|
-
'sonarjs/no-small-switch': 'error',
|
|
23
|
-
'sonarjs/no-identical-functions': 'error',
|
|
24
|
-
'sonarjs/no-redundant-jump': 'error',
|
|
25
|
-
'no-empty-function': ['error', { allow: ['constructors'] }],
|
|
26
|
-
'redundant-undefined/redundant-undefined': 'error',
|
|
27
|
-
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
28
24
|
|
|
29
25
|
// Prevent accidental bugs
|
|
30
26
|
'no-param-reassign': 'error',
|
|
@@ -41,7 +37,7 @@ module.exports = {
|
|
|
41
37
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
42
38
|
|
|
43
39
|
// Type safety
|
|
44
|
-
'@typescript-eslint/no-explicit-any': '
|
|
40
|
+
'@typescript-eslint/no-explicit-any': 'warn', // TODO: set to error
|
|
45
41
|
'@typescript-eslint/explicit-function-return-type': ['error', { allowHigherOrderFunctions: true }],
|
|
46
42
|
|
|
47
43
|
// Disable JS features
|
|
@@ -49,6 +45,7 @@ module.exports = {
|
|
|
49
45
|
'no-console': 'error',
|
|
50
46
|
|
|
51
47
|
// Disabled ESLint rules
|
|
48
|
+
'@typescript-eslint/array-type': 'off',
|
|
52
49
|
'@typescript-eslint/interface-name-prefix': 'off',
|
|
53
50
|
'max-classes-per-file': 'off',
|
|
54
51
|
'@typescript-eslint/no-inferrable-types': 'off',
|
|
@@ -59,7 +56,6 @@ module.exports = {
|
|
|
59
56
|
|
|
60
57
|
// Conventions
|
|
61
58
|
'no-array-constructor': 'error',
|
|
62
|
-
'@typescript-eslint/array-type': 'error',
|
|
63
59
|
'quote-props': ['warn', 'as-needed'],
|
|
64
60
|
'@typescript-eslint/ban-types': [
|
|
65
61
|
'error',
|
|
@@ -106,14 +102,14 @@ module.exports = {
|
|
|
106
102
|
],
|
|
107
103
|
|
|
108
104
|
// Performance improvements + preventing memory leaks
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
"rxjs-angular/prefer-takeuntil": [
|
|
106
|
+
"error",
|
|
111
107
|
{
|
|
112
|
-
alias: [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
checkDestroy:
|
|
116
|
-
}
|
|
108
|
+
"alias": ["untilDestroyed"],
|
|
109
|
+
"checkComplete": true,
|
|
110
|
+
"checkDecorators": ["Component"],
|
|
111
|
+
"checkDestroy": true
|
|
112
|
+
}
|
|
117
113
|
],
|
|
118
114
|
},
|
|
119
115
|
},
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
rules: {
|
|
3
3
|
'@typescript-eslint/explicit-member-accessibility': 'off',
|
|
4
|
-
'@angular-eslint/use-lifecycle-interface': ['error'],
|
|
5
|
-
'@angular-eslint/sort-lifecycle-methods': ['error'],
|
|
6
|
-
'@angular-eslint/no-lifecycle-call': ['error'],
|
|
7
|
-
'@angular-eslint/no-empty-lifecycle-method': ['error'],
|
|
8
|
-
'@angular-eslint/no-async-lifecycle-method': ['error'],
|
|
9
4
|
},
|
|
10
5
|
overrides: [
|
|
11
6
|
{
|
|
12
7
|
files: ['*.ts', '*.tsx'],
|
|
13
8
|
parser: '@typescript-eslint/parser',
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2020,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
project: './tsconfig.json',
|
|
13
|
+
},
|
|
14
14
|
plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'],
|
|
15
15
|
rules: {
|
|
16
16
|
'array-bracket-newline': ['warn', 'consistent'],
|
|
@@ -35,14 +35,14 @@ module.exports = {
|
|
|
35
35
|
curly: ['warn', 'all'],
|
|
36
36
|
'dot-location': ['warn', 'property'],
|
|
37
37
|
'eol-last': 'warn',
|
|
38
|
-
'
|
|
38
|
+
'func-call-spacing': 'warn',
|
|
39
39
|
'function-call-argument-newline': ['warn', 'consistent'],
|
|
40
40
|
'function-paren-newline': ['warn', 'multiline-arguments'],
|
|
41
41
|
'generator-star-spacing': 'off',
|
|
42
42
|
'implicit-arrow-linebreak': 'off',
|
|
43
43
|
indent: 'off',
|
|
44
44
|
'@typescript-eslint/indent': [
|
|
45
|
-
'
|
|
45
|
+
'warn',
|
|
46
46
|
2,
|
|
47
47
|
{
|
|
48
48
|
SwitchCase: 1,
|
|
@@ -57,7 +57,7 @@ module.exports = {
|
|
|
57
57
|
|
|
58
58
|
'keyword-spacing': 'off', // overridden by @typescript-eslint
|
|
59
59
|
'@typescript-eslint/keyword-spacing': ['warn', { after: true, before: true }],
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
'linebreak-style': 'off',
|
|
62
62
|
'max-len': [
|
|
63
63
|
'error',
|
|
@@ -81,18 +81,18 @@ module.exports = {
|
|
|
81
81
|
'no-mixed-operators': ['error'],
|
|
82
82
|
'no-mixed-spaces-and-tabs': 'error',
|
|
83
83
|
'no-multi-spaces': 'error',
|
|
84
|
-
'no-multiple-empty-lines': ['warn', { max: 1
|
|
84
|
+
'no-multiple-empty-lines': ['warn', { max: 1 }], // overwritten NG default
|
|
85
85
|
'no-tabs': 'error',
|
|
86
86
|
'no-trailing-spaces': 'warn',
|
|
87
87
|
'no-unexpected-multiline': 'error',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{ vars:
|
|
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
94
|
],
|
|
95
|
-
'no-duplicate-imports': '
|
|
95
|
+
'no-duplicate-imports': 'warn',
|
|
96
96
|
|
|
97
97
|
'no-useless-constructor': 'off', // overridden by @typescript-eslint
|
|
98
98
|
'@typescript-eslint/no-useless-constructor': ['error'],
|
|
@@ -122,7 +122,6 @@ module.exports = {
|
|
|
122
122
|
'space-before-function-paren': ['warn', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
|
|
123
123
|
'space-in-parens': 'warn',
|
|
124
124
|
'space-infix-ops': 'warn',
|
|
125
|
-
'@typescript-eslint/space-infix-ops': 'warn',
|
|
126
125
|
'space-unary-ops': 'warn',
|
|
127
126
|
'switch-colon-spacing': 'warn',
|
|
128
127
|
'template-curly-spacing': 'warn',
|
|
@@ -132,9 +131,8 @@ module.exports = {
|
|
|
132
131
|
'yield-star-spacing': 'error',
|
|
133
132
|
'no-unused-expressions': 'error',
|
|
134
133
|
'prefer-const': 'error',
|
|
135
|
-
'id-length': ['error', { min: 2, properties: 'never', exceptions: ['i', 'e', 'a', 'b', 'x', 'y', '_'] }], // TODO: remove some of these exceptions
|
|
136
134
|
'@typescript-eslint/no-parameter-properties': 'off',
|
|
137
|
-
'@typescript-eslint/member-ordering': ['
|
|
135
|
+
'@typescript-eslint/member-ordering': ['warn'],
|
|
138
136
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
139
137
|
'error',
|
|
140
138
|
{
|
package/configuration/imports.js
CHANGED
|
@@ -6,6 +6,7 @@ module.exports = {
|
|
|
6
6
|
parserOptions: {
|
|
7
7
|
ecmaVersion: 2020,
|
|
8
8
|
sourceType: 'module',
|
|
9
|
+
project: './tsconfig.json',
|
|
9
10
|
},
|
|
10
11
|
plugins: ['@typescript-eslint', 'simple-import-sort'],
|
|
11
12
|
rules: {
|
|
@@ -14,7 +15,6 @@ module.exports = {
|
|
|
14
15
|
'simple-import-sort/exports': 'error',
|
|
15
16
|
'sort-imports': 'off',
|
|
16
17
|
'import/order': 'off',
|
|
17
|
-
'@typescript-eslint/no-require-imports': 'error',
|
|
18
18
|
'no-restricted-imports': [
|
|
19
19
|
'error',
|
|
20
20
|
{
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeroenpol/eslint-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "ES Lint config made for Angular, configured by Polware",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -47,11 +47,23 @@
|
|
|
47
47
|
"eslint-plugin-sonarjs": "1.0.3",
|
|
48
48
|
"eslint-plugin-unused-imports": "3.2.0",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "6.19.0",
|
|
50
|
-
"@typescript-eslint/parser": "^6.19.0"
|
|
50
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
51
|
+
"typescript": "~5.4.5",
|
|
52
|
+
"typescript-eslint": "^7.16.1"
|
|
51
53
|
},
|
|
52
54
|
"peerDependencies": {
|
|
53
55
|
"eslint": "8.57.0",
|
|
54
|
-
"eslint-
|
|
56
|
+
"eslint-config-prettier": "9.1.0",
|
|
57
|
+
"eslint-plugin-functional": "6.5.1",
|
|
58
|
+
"eslint-plugin-redundant-undefined": "^1.0.0",
|
|
59
|
+
"eslint-plugin-rxjs-angular": "2.0.1",
|
|
60
|
+
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
61
|
+
"eslint-plugin-sonarjs": "1.0.3",
|
|
62
|
+
"eslint-plugin-unused-imports": "3.2.0",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "6.19.0",
|
|
64
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
65
|
+
"typescript": "~5.4.5",
|
|
66
|
+
"typescript-eslint": "^7.16.1"
|
|
55
67
|
},
|
|
56
68
|
"engines": {
|
|
57
69
|
"node": "20"
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"outDir": "./dist/out-tsc",
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"declaration": false,
|
|
8
|
+
"downlevelIteration": true,
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"target": "ES2022",
|
|
14
|
+
"typeRoots": ["node_modules/@types"],
|
|
15
|
+
"lib": ["es2018", "dom"],
|
|
16
|
+
"useDefineForClassFields": false
|
|
17
|
+
}
|
|
18
|
+
}
|