@will-stone/eslint-config 3.1.4 → 4.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/_for_rule_checking.js +21 -0
- package/package.json +7 -3
- package/rules/built-in.js +1 -1
- package/rules/import.js +2 -0
- package/rules/jest.js +25 -0
- package/rules/node.js +29 -0
- package/rules/react.js +2 -0
- package/rules/typescript.js +123 -23
- package/unused-rules.txt +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is just to be used for eslint-find-rules, and should not be used as
|
|
3
|
+
* an eslint configuration.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const tsRules = require('./rules/typescript')
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
plugins: ['@typescript-eslint'],
|
|
10
|
+
extends: [
|
|
11
|
+
require.resolve('./javascript'),
|
|
12
|
+
require.resolve('./react'),
|
|
13
|
+
require.resolve('./node'),
|
|
14
|
+
require.resolve('./jest'),
|
|
15
|
+
require.resolve('./prettier'),
|
|
16
|
+
],
|
|
17
|
+
rules: {
|
|
18
|
+
// Use the TS rules directly as eslint-find-rules cannot see `overrides`.
|
|
19
|
+
...tsRules,
|
|
20
|
+
},
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@will-stone/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "My ESLint config",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"author": "Will Stone",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"eslint-find-unused-rules": "
|
|
12
|
+
"eslint-find-unused-rules": "eslint-find-rules --unused ./_for_rule_checking.js > ./unused-rules.txt",
|
|
13
|
+
"eslint-print-rules": "eslint --no-eslintrc -c ./_for_rule_checking.js --print-config ./_for_rule_checking.js > rules.json"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
"confusing-browser-globals": "^1.0.10",
|
|
18
19
|
"eslint-config-prettier": "^8.3.0",
|
|
19
20
|
"eslint-plugin-import": "^2.24.2",
|
|
20
|
-
"eslint-plugin-jest": "^24.5.
|
|
21
|
+
"eslint-plugin-jest": "^24.5.2",
|
|
21
22
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
22
23
|
"eslint-plugin-node": "^11.1.0",
|
|
23
24
|
"eslint-plugin-prettier": "^4.0.0",
|
|
@@ -27,6 +28,9 @@
|
|
|
27
28
|
"eslint-plugin-switch-case": "^1.1.2",
|
|
28
29
|
"eslint-plugin-unicorn": "^36.0.0"
|
|
29
30
|
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"eslint-find-rules": "^3.6.1"
|
|
33
|
+
},
|
|
30
34
|
"peerDependencies": {
|
|
31
35
|
"eslint": "^7.32.0",
|
|
32
36
|
"typescript": "4.x"
|
package/rules/built-in.js
CHANGED
|
@@ -756,7 +756,7 @@ module.exports = {
|
|
|
756
756
|
'use-isnan': 'error',
|
|
757
757
|
|
|
758
758
|
// Enforce comparing typeof expressions against valid strings.
|
|
759
|
-
'valid-typeof': 'error',
|
|
759
|
+
'valid-typeof': ['error', { requireStringLiterals: true }],
|
|
760
760
|
|
|
761
761
|
// By default variable declarations are always moved (“hoisted”) invisibly
|
|
762
762
|
// to the top of their containing scope by the JavaScript interpreter.
|
package/rules/import.js
CHANGED
|
@@ -32,6 +32,8 @@ module.exports = {
|
|
|
32
32
|
'import/extensions': 'off',
|
|
33
33
|
'import/first': 'off',
|
|
34
34
|
'import/group-exports': 'off',
|
|
35
|
+
'import/no-import-module-exports': 'off',
|
|
36
|
+
'import/no-relative-packages': 'off',
|
|
35
37
|
'import/max-dependencies': 'off',
|
|
36
38
|
'import/named': 'off',
|
|
37
39
|
'import/namespace': 'off',
|
package/rules/jest.js
CHANGED
|
@@ -8,6 +8,8 @@ module.exports = {
|
|
|
8
8
|
// lowercase letter. This provides more readable test failures.
|
|
9
9
|
'jest/lowercase-name': 'warn',
|
|
10
10
|
|
|
11
|
+
'jest/max-nested-describe': 'off',
|
|
12
|
+
|
|
11
13
|
// Consistent expect methods
|
|
12
14
|
'jest/no-alias-methods': 'error',
|
|
13
15
|
|
|
@@ -17,12 +19,27 @@ module.exports = {
|
|
|
17
19
|
// Do not allow multiple beforeEach, for example
|
|
18
20
|
'jest/no-duplicate-hooks': 'error',
|
|
19
21
|
|
|
22
|
+
'jest/no-hooks': 'off',
|
|
23
|
+
|
|
24
|
+
// Conditional logic in tests is usually an indication that a test is attempting to cover too much
|
|
25
|
+
'jest/no-if': 'error',
|
|
26
|
+
|
|
27
|
+
'jest/no-large-snapshots': 'off',
|
|
28
|
+
|
|
29
|
+
'jest/no-restricted-matchers': 'off',
|
|
30
|
+
|
|
20
31
|
// No standalone expect in a describe block
|
|
21
32
|
'jest/no-standalone-expect': 'error',
|
|
22
33
|
|
|
23
34
|
// Tests shouldn't return anything
|
|
24
35
|
'jest/no-test-return-statement': 'error',
|
|
25
36
|
|
|
37
|
+
'jest/prefer-called-with': 'off',
|
|
38
|
+
|
|
39
|
+
'jest/prefer-expect-assertions': 'off',
|
|
40
|
+
|
|
41
|
+
'jest/prefer-expect-resolves': 'warn',
|
|
42
|
+
|
|
26
43
|
// beforeEach, beforeAll, afterEach etc. should be at top of test block
|
|
27
44
|
'jest/prefer-hooks-on-top': 'error',
|
|
28
45
|
|
|
@@ -31,6 +48,10 @@ module.exports = {
|
|
|
31
48
|
// Jest keeps track of changes, and they can be restored.
|
|
32
49
|
'jest/prefer-spy-on': 'error',
|
|
33
50
|
|
|
51
|
+
'jest/prefer-strict-equal': 'error',
|
|
52
|
+
|
|
53
|
+
'jest/prefer-to-be': 'warn',
|
|
54
|
+
|
|
34
55
|
// .toBe(null) -> .toBeNull()
|
|
35
56
|
'jest/prefer-to-be-null': 'error',
|
|
36
57
|
|
|
@@ -50,10 +71,14 @@ module.exports = {
|
|
|
50
71
|
// Requiring a message ensures that the intended error is thrown
|
|
51
72
|
'jest/require-to-throw-message': 'error',
|
|
52
73
|
|
|
74
|
+
'jest/require-top-level-describe': 'off',
|
|
75
|
+
|
|
53
76
|
// Titles are...
|
|
54
77
|
// - not empty
|
|
55
78
|
// - is a string
|
|
56
79
|
// - not prefixed with their block name
|
|
57
80
|
// - have no leading or trailing spaces
|
|
58
81
|
'jest/valid-title': 'error',
|
|
82
|
+
|
|
83
|
+
'jest/unbound-method': 'off',
|
|
59
84
|
}
|
package/rules/node.js
CHANGED
|
@@ -37,4 +37,33 @@ module.exports = {
|
|
|
37
37
|
// Not sure I need this...?
|
|
38
38
|
// TODO check others' configs to see how they use this.
|
|
39
39
|
'node/shebang': 'off',
|
|
40
|
+
|
|
41
|
+
// Turn these off until I work out if I need them
|
|
42
|
+
'node/exports-style': 'off',
|
|
43
|
+
'node/file-extension-in-import': 'off',
|
|
44
|
+
'node/no-callback-literal': 'off',
|
|
45
|
+
'node/no-deprecated-api': 'off',
|
|
46
|
+
'node/no-exports-assign': 'off',
|
|
47
|
+
'node/no-extraneous-import': 'off',
|
|
48
|
+
'node/no-extraneous-require': 'off',
|
|
49
|
+
'node/no-missing-import': 'off',
|
|
50
|
+
'node/no-missing-require': 'off',
|
|
51
|
+
'node/no-new-require': 'off',
|
|
52
|
+
'node/no-restricted-import': 'off',
|
|
53
|
+
'node/no-unpublished-bin': 'off',
|
|
54
|
+
'node/no-unpublished-import': 'off',
|
|
55
|
+
'node/no-unpublished-require': 'off',
|
|
56
|
+
'node/no-unsupported-features/es-builtins': 'off',
|
|
57
|
+
'node/no-unsupported-features/es-syntax': 'off',
|
|
58
|
+
'node/no-unsupported-features/node-builtins': 'off',
|
|
59
|
+
'node/prefer-global/buffer': 'off',
|
|
60
|
+
'node/prefer-global/console': 'off',
|
|
61
|
+
'node/prefer-global/process': 'off',
|
|
62
|
+
'node/prefer-global/text-decoder': 'off',
|
|
63
|
+
'node/prefer-global/text-encoder': 'off',
|
|
64
|
+
'node/prefer-global/url': 'off',
|
|
65
|
+
'node/prefer-global/url-search-params': 'off',
|
|
66
|
+
'node/prefer-promises/dns': 'off',
|
|
67
|
+
'node/prefer-promises/fs': 'off',
|
|
68
|
+
'node/process-exit-as-throw': 'off',
|
|
40
69
|
}
|
package/rules/react.js
CHANGED
package/rules/typescript.js
CHANGED
|
@@ -24,8 +24,6 @@ module.exports = {
|
|
|
24
24
|
'no-new-symbol': 'off',
|
|
25
25
|
// ts(2349)
|
|
26
26
|
'no-obj-calls': 'off',
|
|
27
|
-
// ts(2451)
|
|
28
|
-
'no-redeclare': 'off',
|
|
29
27
|
// ts(2408)
|
|
30
28
|
'no-setter-return': 'off',
|
|
31
29
|
// ts(2376)
|
|
@@ -80,51 +78,84 @@ module.exports = {
|
|
|
80
78
|
*/
|
|
81
79
|
'@typescript-eslint/await-thenable': 'off',
|
|
82
80
|
'@typescript-eslint/dot-notation': 'off',
|
|
81
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
82
|
+
'@typescript-eslint/no-base-to-string': 'off',
|
|
83
83
|
'@typescript-eslint/no-confusing-void-expression': 'off',
|
|
84
84
|
'@typescript-eslint/no-floating-promises': 'off',
|
|
85
85
|
'@typescript-eslint/no-for-in-array': 'off',
|
|
86
86
|
'@typescript-eslint/no-implied-eval': 'off',
|
|
87
|
+
'@typescript-eslint/no-meaningless-void-operator': 'off',
|
|
87
88
|
'@typescript-eslint/no-misused-promises': 'off',
|
|
89
|
+
'@typescript-eslint/no-throw-literal': 'off',
|
|
90
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
|
|
91
|
+
'@typescript-eslint/no-unnecessary-condition': 'off',
|
|
92
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'off',
|
|
93
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
|
|
88
94
|
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
|
95
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
89
96
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
90
97
|
'@typescript-eslint/no-unsafe-call': 'off',
|
|
91
98
|
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
92
99
|
'@typescript-eslint/no-unsafe-return': 'off',
|
|
93
100
|
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
|
101
|
+
'@typescript-eslint/prefer-includes': 'off',
|
|
102
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
|
|
103
|
+
'@typescript-eslint/prefer-readonly': 'off',
|
|
94
104
|
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
|
|
105
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
|
|
106
|
+
'@typescript-eslint/prefer-return-this-type': 'off',
|
|
95
107
|
'@typescript-eslint/prefer-regexp-exec': 'off',
|
|
108
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
|
|
96
109
|
'@typescript-eslint/promise-function-async': 'off',
|
|
110
|
+
'@typescript-eslint/require-array-sort-compare': 'off',
|
|
97
111
|
'@typescript-eslint/require-await': 'off',
|
|
98
112
|
'@typescript-eslint/restrict-plus-operands': 'off',
|
|
99
113
|
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
114
|
+
'@typescript-eslint/return-await': 'off',
|
|
115
|
+
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
116
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'off',
|
|
100
117
|
'@typescript-eslint/unbound-method': 'off',
|
|
101
118
|
|
|
102
119
|
/**
|
|
103
|
-
*
|
|
120
|
+
* The rest
|
|
104
121
|
*/
|
|
105
122
|
|
|
106
|
-
//
|
|
107
|
-
'@typescript-eslint/
|
|
123
|
+
// Requires using T[] over Array<T> for arrays
|
|
124
|
+
'@typescript-eslint/array-type': ['warn', { default: 'array' }],
|
|
108
125
|
|
|
109
|
-
//
|
|
110
|
-
'@typescript-eslint/
|
|
126
|
+
// Bans // tslint:<rule-flag> comments from being used
|
|
127
|
+
'@typescript-eslint/ban-tslint-comment': 'warn',
|
|
111
128
|
|
|
112
|
-
//
|
|
113
|
-
'
|
|
114
|
-
'@typescript-eslint/no-duplicate-imports': ['error'],
|
|
129
|
+
// Ensures that literals on classes are exposed in a consistent style
|
|
130
|
+
'@typescript-eslint/class-literal-property-style': 'warn',
|
|
115
131
|
|
|
116
|
-
//
|
|
117
|
-
'
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
// Enforce the use of the record type
|
|
133
|
+
'@typescript-eslint/consistent-indexed-object-style': 'warn',
|
|
134
|
+
|
|
135
|
+
// Enforces consistent usage of type assertions
|
|
136
|
+
'@typescript-eslint/consistent-type-assertions': 'error',
|
|
137
|
+
|
|
138
|
+
// Enforce using interfaces for object type definitions
|
|
139
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
|
140
|
+
|
|
141
|
+
// Enforces consistent usage of type imports
|
|
142
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
143
|
+
'warn',
|
|
144
|
+
{ prefer: 'type-imports' },
|
|
121
145
|
],
|
|
122
146
|
|
|
123
|
-
|
|
124
|
-
'
|
|
147
|
+
// Enforce default parameters to be last
|
|
148
|
+
'default-param-last': 'off',
|
|
149
|
+
'@typescript-eslint/default-param-last': ['error'],
|
|
125
150
|
|
|
126
|
-
//
|
|
127
|
-
'@typescript-eslint/
|
|
151
|
+
// Don't mind if functions do not have return types.
|
|
152
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
153
|
+
|
|
154
|
+
// Require explicit accessibility modifiers ("public") on class properties and methods
|
|
155
|
+
'@typescript-eslint/explicit-member-accessibility': 'warn',
|
|
156
|
+
|
|
157
|
+
// Initialise vairables however you like
|
|
158
|
+
'@typescript-eslint/init-declarations': 'off',
|
|
128
159
|
|
|
129
160
|
'lines-between-class-members': 'off',
|
|
130
161
|
'@typescript-eslint/lines-between-class-members': [
|
|
@@ -146,34 +177,98 @@ module.exports = {
|
|
|
146
177
|
// }
|
|
147
178
|
'@typescript-eslint/method-signature-style': 'warn',
|
|
148
179
|
|
|
180
|
+
// Disallow non-null assertion in locations that may be confusing
|
|
181
|
+
'@typescript-eslint/no-confusing-non-null-assertion': 'warn',
|
|
182
|
+
|
|
183
|
+
// Disallow duplicate imports
|
|
184
|
+
'no-duplicate-imports': 'off',
|
|
185
|
+
'@typescript-eslint/no-duplicate-imports': 'error',
|
|
186
|
+
|
|
149
187
|
// Disallow duplicate class members
|
|
150
188
|
'@typescript-eslint/no-dupe-class-members': 'error',
|
|
151
189
|
|
|
190
|
+
'@typescript-eslint/no-dynamic-delete': 'warn',
|
|
191
|
+
|
|
152
192
|
// ❌ const bar = foo!!!.bar
|
|
153
193
|
// ✅ const bar = foo!.bar
|
|
154
194
|
'@typescript-eslint/no-extra-non-null-assertion': 'warn',
|
|
155
195
|
|
|
156
|
-
//
|
|
157
|
-
'@typescript-eslint/no-
|
|
196
|
+
// Warns when a class is accidentally used as a namespace
|
|
197
|
+
'@typescript-eslint/no-extraneous-class': 'error',
|
|
198
|
+
|
|
199
|
+
// Disallow usage of the implicit any type in catch clauses
|
|
200
|
+
'@typescript-eslint/no-implicit-any-catch': 'warn',
|
|
158
201
|
|
|
159
202
|
// Disallow this keywords outside of classes or class-like objects
|
|
160
203
|
'no-invalid-this': 'off',
|
|
161
204
|
'@typescript-eslint/no-invalid-this': 'error',
|
|
162
205
|
|
|
206
|
+
// Disallows usage of void type outside of generic or return types
|
|
207
|
+
'@typescript-eslint/no-invalid-void-type': 'error',
|
|
208
|
+
|
|
209
|
+
// Disallow function declarations that contain unsafe references inside loop statements
|
|
210
|
+
'no-loop-func': 'off',
|
|
211
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
212
|
+
|
|
163
213
|
// Disallow literal numbers that lose precision
|
|
164
214
|
'no-loss-of-precision': 'off',
|
|
165
215
|
'@typescript-eslint/no-loss-of-precision': ['error'],
|
|
166
216
|
|
|
217
|
+
// Disallowing magic numbers causes all sorts of problems
|
|
218
|
+
'@typescript-eslint/no-magic-numbers': 'off',
|
|
219
|
+
|
|
220
|
+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
|
221
|
+
|
|
222
|
+
// Not sure if needed
|
|
223
|
+
'@typescript-eslint/no-parameter-properties': 'off',
|
|
224
|
+
|
|
225
|
+
'no-redeclare': 'off',
|
|
226
|
+
'@typescript-eslint/no-redeclare': 'error',
|
|
227
|
+
|
|
228
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
229
|
+
|
|
230
|
+
'no-restricted-imports': 'off',
|
|
231
|
+
'@typescript-eslint/no-restricted-imports': 'off',
|
|
232
|
+
|
|
167
233
|
// Disallow variable declarations from shadowing variables declared in the outer scope
|
|
168
234
|
'no-shadow': 'off',
|
|
169
235
|
'@typescript-eslint/no-shadow': ['error'],
|
|
170
236
|
|
|
237
|
+
// Aliasing can be useful
|
|
238
|
+
'@typescript-eslint/no-type-alias': 'off',
|
|
239
|
+
|
|
240
|
+
// Disallows unnecessary constraints on generic types
|
|
241
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
|
|
242
|
+
|
|
171
243
|
// Aims to eliminate unused expressions which have no effect on the state of the program.
|
|
172
244
|
'no-unused-expressions': 'off',
|
|
173
245
|
'@typescript-eslint/no-unused-expressions': ['error'],
|
|
174
246
|
|
|
175
|
-
//
|
|
176
|
-
'
|
|
247
|
+
// Variables must be used unless name ends with "ignored"
|
|
248
|
+
'no-unused-vars': 'off',
|
|
249
|
+
'@typescript-eslint/no-unused-vars': [
|
|
250
|
+
'error',
|
|
251
|
+
{ varsIgnorePattern: '[iI]gnored' },
|
|
252
|
+
],
|
|
253
|
+
|
|
254
|
+
'no-use-before-define': 'off',
|
|
255
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
256
|
+
|
|
257
|
+
'no-useless-constructor': 'off',
|
|
258
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
259
|
+
|
|
260
|
+
'padding-line-between-statements': 'off',
|
|
261
|
+
'@typescript-eslint/padding-line-between-statements': [
|
|
262
|
+
'error',
|
|
263
|
+
{ blankLine: 'always', prev: 'multiline-block-like', next: '*' },
|
|
264
|
+
],
|
|
265
|
+
|
|
266
|
+
'@typescript-eslint/prefer-enum-initializers': 'error',
|
|
267
|
+
|
|
268
|
+
// Unicorn does this better by providing a fixer
|
|
269
|
+
'@typescript-eslint/prefer-for-of': 'off',
|
|
270
|
+
|
|
271
|
+
'@typescript-eslint/prefer-function-type': 'warn',
|
|
177
272
|
|
|
178
273
|
// Require that all enum members be literal values to prevent unintended enum member name shadow issues.
|
|
179
274
|
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
|
@@ -197,4 +292,9 @@ module.exports = {
|
|
|
197
292
|
// This rule is aimed at ensuring there are spaces around infix operators.
|
|
198
293
|
'space-infix-ops': 'off',
|
|
199
294
|
'@typescript-eslint/space-infix-ops': ['warn', { int32Hint: false }],
|
|
295
|
+
|
|
296
|
+
// Not sure if required yet. Might be too strict and produce noist code.
|
|
297
|
+
'@typescript-eslint/typedef': 'off',
|
|
298
|
+
|
|
299
|
+
'@typescript-eslint/unified-signatures': 'error',
|
|
200
300
|
}
|
package/unused-rules.txt
ADDED
|
File without changes
|