eslint-config-react-app-new 2.0.1 → 2.0.2
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/base.js +5 -1
- package/index.js +193 -23
- package/jest.js +3 -4
- package/package.json +1 -1
- package/react.js +10 -5
package/base.js
CHANGED
|
@@ -2,6 +2,10 @@ const react = require('eslint-plugin-react');
|
|
|
2
2
|
const babelParser = require('@babel/eslint-parser');
|
|
3
3
|
const globals = require('globals');
|
|
4
4
|
|
|
5
|
+
if (!process.env.NODE_ENV) {
|
|
6
|
+
process.env.NODE_ENV = 'development';
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
module.exports = [
|
|
6
10
|
{
|
|
7
11
|
languageOptions: {
|
|
@@ -14,7 +18,7 @@ module.exports = [
|
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
// true means writeable, false means readonly, 'off' means disabled
|
|
17
|
-
|
|
21
|
+
globals: {
|
|
18
22
|
...globals.browser,
|
|
19
23
|
...globals.node,
|
|
20
24
|
...globals.commonjs,
|
package/index.js
CHANGED
|
@@ -4,16 +4,18 @@ const baseConfig = require('./base');
|
|
|
4
4
|
const reactConfig = require('./react');
|
|
5
5
|
const jsxA11yConfig = require('./jsx-a11y');
|
|
6
6
|
const importConfig = require('./import');
|
|
7
|
+
const jestConfig = require('./jest');
|
|
7
8
|
|
|
8
9
|
module.exports = [
|
|
10
|
+
baseConfig,
|
|
11
|
+
reactConfig,
|
|
12
|
+
jsxA11yConfig,
|
|
13
|
+
importConfig,
|
|
14
|
+
jestConfig,
|
|
9
15
|
{
|
|
10
|
-
extends: [baseConfig, reactConfig, jsxA11yConfig, importConfig],
|
|
11
|
-
// NOTE: When adding rules here, you need to make sure they are compatible with
|
|
12
|
-
// `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.
|
|
13
16
|
rules: {
|
|
14
|
-
// http://eslint.org/docs/rules/
|
|
15
17
|
'array-callback-return': 'warn',
|
|
16
|
-
'default-case': ['warn', { commentPattern: '^no
|
|
18
|
+
'default-case': ['warn', { commentPattern: '^no[-\\s]+default$' }],
|
|
17
19
|
'dot-location': ['warn', 'property'],
|
|
18
20
|
eqeqeq: ['warn', 'smart'],
|
|
19
21
|
'new-parens': 'warn',
|
|
@@ -93,8 +95,13 @@ module.exports = [
|
|
|
93
95
|
'no-unused-vars': [
|
|
94
96
|
'warn',
|
|
95
97
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
vars: 'all',
|
|
99
|
+
args: 'after-used',
|
|
100
|
+
caughtErrors: 'none',
|
|
101
|
+
ignoreRestSiblings: true,
|
|
102
|
+
varsIgnorePattern: '^_',
|
|
103
|
+
destructuredArrayIgnorePattern: '^_',
|
|
104
|
+
argsIgnorePattern: '^_|^err|^ev'
|
|
98
105
|
}
|
|
99
106
|
],
|
|
100
107
|
'no-use-before-define': [
|
|
@@ -141,21 +148,110 @@ module.exports = [
|
|
|
141
148
|
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting'
|
|
142
149
|
}
|
|
143
150
|
],
|
|
144
|
-
'getter-return': 'warn'
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'
|
|
151
|
+
'getter-return': 'warn',
|
|
152
|
+
'linebreak-style': ['warn', 'unix'],
|
|
153
|
+
'semi-spacing': ['warn', { before: false }],
|
|
154
|
+
'no-extra-semi': 'warn',
|
|
155
|
+
'padded-blocks': ['warn', 'never'],
|
|
156
|
+
'one-var-declaration-per-line': ['warn', 'initializations'],
|
|
157
|
+
'spaced-comment': ['warn', 'always'],
|
|
158
|
+
'space-in-parens': ['warn', 'never'],
|
|
159
|
+
'space-before-function-paren': [
|
|
160
|
+
'warn',
|
|
161
|
+
{
|
|
162
|
+
anonymous: 'never',
|
|
163
|
+
named: 'never',
|
|
164
|
+
asyncArrow: 'always'
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
'space-unary-ops': 'warn',
|
|
168
|
+
'space-infix-ops': 'warn',
|
|
169
|
+
'space-before-blocks': 'warn',
|
|
170
|
+
'no-trailing-spaces': ['warn', { ignoreComments: true }],
|
|
171
|
+
'key-spacing': ['warn', { mode: 'strict' }],
|
|
172
|
+
'switch-colon-spacing': 'warn',
|
|
173
|
+
'func-call-spacing': ['warn', 'never'],
|
|
174
|
+
'keyword-spacing': 'warn',
|
|
175
|
+
'no-multiple-empty-lines': [
|
|
176
|
+
'warn',
|
|
177
|
+
{
|
|
178
|
+
max: 1,
|
|
179
|
+
maxEOF: 0,
|
|
180
|
+
maxBOF: 0
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
'default-param-last': 'error',
|
|
184
|
+
curly: 'error',
|
|
185
|
+
'dot-notation': 'warn',
|
|
186
|
+
'symbol-description': 'error',
|
|
187
|
+
'prefer-template': 'warn',
|
|
188
|
+
'no-unexpected-multiline': 'warn',
|
|
189
|
+
'no-else-return': 'warn',
|
|
190
|
+
'guard-for-in': 'error',
|
|
191
|
+
'no-multi-spaces': [
|
|
192
|
+
'warn',
|
|
193
|
+
{
|
|
194
|
+
ignoreEOLComments: true,
|
|
195
|
+
exceptions: {
|
|
196
|
+
VariableDeclarator: true,
|
|
197
|
+
ImportDeclaration: true
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
'no-floating-decimal': 'warn',
|
|
202
|
+
yoda: 'warn',
|
|
203
|
+
'no-unmodified-loop-condition': 'warn',
|
|
204
|
+
'wrap-iife': ['error', 'inside'],
|
|
205
|
+
'lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],
|
|
206
|
+
'padding-line-between-statements': [
|
|
207
|
+
'warn',
|
|
208
|
+
{
|
|
209
|
+
blankLine: 'always',
|
|
210
|
+
prev: [
|
|
211
|
+
'multiline-block-like',
|
|
212
|
+
'multiline-expression',
|
|
213
|
+
'const',
|
|
214
|
+
'let',
|
|
215
|
+
'var',
|
|
216
|
+
'cjs-import',
|
|
217
|
+
'import',
|
|
218
|
+
'export',
|
|
219
|
+
'cjs-export',
|
|
220
|
+
'class',
|
|
221
|
+
'throw',
|
|
222
|
+
'directive'
|
|
223
|
+
],
|
|
224
|
+
next: '*'
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
blankLine: 'always',
|
|
228
|
+
prev: '*',
|
|
229
|
+
next: [
|
|
230
|
+
'multiline-block-like',
|
|
231
|
+
'multiline-expression',
|
|
232
|
+
'const',
|
|
233
|
+
'let',
|
|
234
|
+
'var',
|
|
235
|
+
'cjs-import',
|
|
236
|
+
'import',
|
|
237
|
+
'export',
|
|
238
|
+
'cjs-export',
|
|
239
|
+
'class',
|
|
240
|
+
'throw',
|
|
241
|
+
'return'
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
{ blankLine: 'any', prev: ['cjs-import', 'import'], next: ['cjs-import', 'import'] },
|
|
245
|
+
{ blankLine: 'any', prev: ['export', 'cjs-export'], next: ['export', 'cjs-export'] },
|
|
246
|
+
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] }
|
|
247
|
+
]
|
|
151
248
|
}
|
|
152
249
|
},
|
|
153
250
|
{
|
|
154
251
|
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
155
252
|
plugins: {
|
|
156
|
-
'@typescript-eslint': tseslint
|
|
253
|
+
'@typescript-eslint': tseslint.plugin
|
|
157
254
|
},
|
|
158
|
-
extends: ['@typescript-eslint/eslint-recommended'],
|
|
159
255
|
languageOptions: {
|
|
160
256
|
parser: tseslint.parser,
|
|
161
257
|
sourceType: 'module',
|
|
@@ -170,13 +266,76 @@ module.exports = [
|
|
|
170
266
|
}
|
|
171
267
|
},
|
|
172
268
|
rules: {
|
|
173
|
-
|
|
269
|
+
...tseslint.configs.eslintRecommended.rules,
|
|
174
270
|
'default-case': 'off',
|
|
175
|
-
|
|
271
|
+
'@typescript-eslint/ban-tslint-comment': 'warn',
|
|
176
272
|
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
177
|
-
'
|
|
178
|
-
'@typescript-eslint/
|
|
179
|
-
|
|
273
|
+
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
274
|
+
'@typescript-eslint/array-type': [
|
|
275
|
+
'warn',
|
|
276
|
+
{
|
|
277
|
+
default: 'array-simple'
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
'@typescript-eslint/class-literal-property-style': 'warn',
|
|
281
|
+
'@typescript-eslint/consistent-indexed-object-style': 'warn',
|
|
282
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
|
283
|
+
'@typescript-eslint/naming-convention': [
|
|
284
|
+
'error',
|
|
285
|
+
{
|
|
286
|
+
selector: 'typeLike',
|
|
287
|
+
format: ['PascalCase']
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
'@typescript-eslint/no-confusing-non-null-assertion': 'warn',
|
|
291
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
292
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
293
|
+
'@typescript-eslint/no-extraneous-class': 'error',
|
|
294
|
+
'@typescript-eslint/no-invalid-void-type': 'error',
|
|
295
|
+
'@typescript-eslint/no-import-type-side-effects': 'error',
|
|
296
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
297
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
298
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
|
|
299
|
+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'warn',
|
|
300
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
|
301
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
302
|
+
'@typescript-eslint/no-empty-object-type': [
|
|
303
|
+
'error',
|
|
304
|
+
{
|
|
305
|
+
allowInterfaces: 'never',
|
|
306
|
+
allowObjectTypes: 'always'
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
'@typescript-eslint/no-redeclare': [
|
|
310
|
+
'error',
|
|
311
|
+
{
|
|
312
|
+
ignoreDeclarationMerge: true
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
'@typescript-eslint/no-require-imports': ['error', {
|
|
316
|
+
allowAsImport: false
|
|
317
|
+
}],
|
|
318
|
+
'@typescript-eslint/no-this-alias': [
|
|
319
|
+
'error',
|
|
320
|
+
{
|
|
321
|
+
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
|
|
322
|
+
allowedNames: ['self'] // Allow `const self = this`; `[]` by default
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
'@typescript-eslint/no-wrapper-object-types': 'error',
|
|
326
|
+
'@typescript-eslint/prefer-as-const': 'warn',
|
|
327
|
+
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
|
328
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
329
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
330
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
331
|
+
'@typescript-eslint/unified-signatures': 'warn',
|
|
332
|
+
|
|
333
|
+
'default-param-last': 'off',
|
|
334
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
335
|
+
|
|
336
|
+
'no-loop-func': 'off',
|
|
337
|
+
'@typescript-eslint/no-loop-func': 'warn',
|
|
338
|
+
|
|
180
339
|
'no-use-before-define': 'off',
|
|
181
340
|
'@typescript-eslint/no-use-before-define': [
|
|
182
341
|
'warn',
|
|
@@ -187,6 +346,7 @@ module.exports = [
|
|
|
187
346
|
typedefs: false
|
|
188
347
|
}
|
|
189
348
|
],
|
|
349
|
+
|
|
190
350
|
'no-unused-expressions': 'off',
|
|
191
351
|
'@typescript-eslint/no-unused-expressions': [
|
|
192
352
|
'error',
|
|
@@ -196,14 +356,24 @@ module.exports = [
|
|
|
196
356
|
allowTaggedTemplates: true
|
|
197
357
|
}
|
|
198
358
|
],
|
|
359
|
+
|
|
199
360
|
'no-unused-vars': 'off',
|
|
200
361
|
'@typescript-eslint/no-unused-vars': [
|
|
201
362
|
'warn',
|
|
202
363
|
{
|
|
203
|
-
|
|
204
|
-
|
|
364
|
+
vars: 'all',
|
|
365
|
+
args: 'after-used',
|
|
366
|
+
caughtErrors: 'none',
|
|
367
|
+
ignoreRestSiblings: true,
|
|
368
|
+
varsIgnorePattern: '^_',
|
|
369
|
+
destructuredArrayIgnorePattern: '^_',
|
|
370
|
+
argsIgnorePattern: '^_|^err|^ev'
|
|
205
371
|
}
|
|
206
372
|
],
|
|
373
|
+
|
|
374
|
+
'no-array-constructor': 'off',
|
|
375
|
+
'@typescript-eslint/no-array-constructor': 'warn',
|
|
376
|
+
|
|
207
377
|
'no-useless-constructor': 'off',
|
|
208
378
|
'@typescript-eslint/no-useless-constructor': 'warn'
|
|
209
379
|
}
|
package/jest.js
CHANGED
|
@@ -32,17 +32,16 @@ module.exports = [
|
|
|
32
32
|
'jest/valid-title': 'warn',
|
|
33
33
|
|
|
34
34
|
// https://github.com/testing-library/eslint-plugin-testing-library
|
|
35
|
-
'testing-library/await-async-
|
|
35
|
+
'testing-library/await-async-queries': 'error',
|
|
36
36
|
'testing-library/await-async-utils': 'error',
|
|
37
|
-
'testing-library/no-await-sync-
|
|
37
|
+
'testing-library/no-await-sync-queries': 'error',
|
|
38
38
|
'testing-library/no-container': 'error',
|
|
39
39
|
'testing-library/no-debugging-utils': 'error',
|
|
40
40
|
'testing-library/no-dom-import': ['error', 'react'],
|
|
41
41
|
'testing-library/no-node-access': 'error',
|
|
42
42
|
'testing-library/no-promise-in-fire-event': 'error',
|
|
43
|
-
'testing-library/no-render-in-
|
|
43
|
+
'testing-library/no-render-in-lifecycle': 'error',
|
|
44
44
|
'testing-library/no-unnecessary-act': 'error',
|
|
45
|
-
'testing-library/no-wait-for-empty-callback': 'error',
|
|
46
45
|
'testing-library/no-wait-for-multiple-assertions': 'error',
|
|
47
46
|
'testing-library/no-wait-for-side-effects': 'error',
|
|
48
47
|
'testing-library/no-wait-for-snapshot': 'error',
|
package/package.json
CHANGED
package/react.js
CHANGED
|
@@ -3,9 +3,9 @@ const reactHooksPlugin = require('eslint-plugin-react-hooks');
|
|
|
3
3
|
|
|
4
4
|
const hasJsxRuntime = (() => {
|
|
5
5
|
try {
|
|
6
|
-
|
|
6
|
+
require.resolve('react/jsx-runtime');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
return true;
|
|
9
9
|
} catch {}
|
|
10
10
|
|
|
11
11
|
return false;
|
|
@@ -17,7 +17,6 @@ module.exports = [
|
|
|
17
17
|
react,
|
|
18
18
|
'react-hooks': reactHooksPlugin
|
|
19
19
|
},
|
|
20
|
-
extends: ['react-hooks/recommended'],
|
|
21
20
|
settings: {
|
|
22
21
|
react: {
|
|
23
22
|
version: 'detect'
|
|
@@ -27,7 +26,13 @@ module.exports = [
|
|
|
27
26
|
// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
|
|
28
27
|
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
|
|
29
28
|
'react/forward-ref-uses-ref': 'warn',
|
|
30
|
-
'react/jsx-boolean-value': [
|
|
29
|
+
'react/jsx-boolean-value': [
|
|
30
|
+
'warn',
|
|
31
|
+
'never',
|
|
32
|
+
{
|
|
33
|
+
always: ['value']
|
|
34
|
+
}
|
|
35
|
+
],
|
|
31
36
|
'react/jsx-key': ['warn', { checkFragmentShorthand: true, warnOnDuplicates: true }],
|
|
32
37
|
'react/jsx-no-comment-textnodes': 'warn',
|
|
33
38
|
'react/jsx-no-duplicate-props': 'warn',
|
|
@@ -54,7 +59,7 @@ module.exports = [
|
|
|
54
59
|
'react/require-render-return': 'error',
|
|
55
60
|
'react/style-prop-object': 'warn',
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
...reactHooksPlugin.configs.recommended.rules,
|
|
58
63
|
'react-hooks/refs': 'off'
|
|
59
64
|
}
|
|
60
65
|
}
|