eslint-config-react-app 3.0.8 → 4.0.1
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/README.md +1 -1
- package/index.js +48 -2
- package/package.json +12 -5
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ If you want to use this ESLint configuration in a project not built with Create
|
|
|
19
19
|
First, install this package, ESLint and the necessary plugins.
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
npm install --save-dev eslint-config-react-app babel-eslint@9.x eslint@5.x eslint-plugin-flowtype@2.x eslint-plugin-import@2.x eslint-plugin-jsx-a11y@6.x eslint-plugin-react@7.x
|
|
22
|
+
npm install --save-dev eslint-config-react-app babel-eslint@9.x eslint@5.x eslint-plugin-flowtype@2.x eslint-plugin-import@2.x eslint-plugin-jsx-a11y@6.x eslint-plugin-react@7.x eslint-plugin-react-hooks@1.5.0
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Then create a file named `.eslintrc.json` with following contents in the root folder of your project:
|
package/index.js
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
// This is dangerous as it hides accidentally undefined variables.
|
|
22
22
|
// We blacklist the globals that we deem potentially confusing.
|
|
23
23
|
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
|
|
24
|
-
|
|
24
|
+
const restrictedGlobals = require('confusing-browser-globals');
|
|
25
25
|
|
|
26
26
|
module.exports = {
|
|
27
27
|
root: true,
|
|
28
28
|
|
|
29
29
|
parser: 'babel-eslint',
|
|
30
30
|
|
|
31
|
-
plugins: ['import', 'flowtype', 'jsx-a11y', 'react'],
|
|
31
|
+
plugins: ['import', 'flowtype', 'jsx-a11y', 'react', 'react-hooks'],
|
|
32
32
|
|
|
33
33
|
env: {
|
|
34
34
|
browser: true,
|
|
@@ -52,6 +52,48 @@ module.exports = {
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
|
|
55
|
+
overrides: {
|
|
56
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
57
|
+
parser: '@typescript-eslint/parser',
|
|
58
|
+
parserOptions: {
|
|
59
|
+
ecmaVersion: 2018,
|
|
60
|
+
sourceType: 'module',
|
|
61
|
+
ecmaFeatures: {
|
|
62
|
+
jsx: true,
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// typescript-eslint specific options
|
|
66
|
+
warnOnUnsupportedTypeScriptVersion: true,
|
|
67
|
+
},
|
|
68
|
+
plugins: ['@typescript-eslint'],
|
|
69
|
+
// If adding a typescript-eslint version of an existing ESLint rule,
|
|
70
|
+
// make sure to disable the ESLint rule here.
|
|
71
|
+
rules: {
|
|
72
|
+
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
|
|
73
|
+
'default-case': 'off',
|
|
74
|
+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
|
|
75
|
+
'no-dupe-class-members': 'off',
|
|
76
|
+
|
|
77
|
+
// Add TypeScript specific rules (and turn off ESLint equivalents)
|
|
78
|
+
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
|
|
79
|
+
'no-array-constructor': 'off',
|
|
80
|
+
'@typescript-eslint/no-array-constructor': 'warn',
|
|
81
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
82
|
+
'no-unused-vars': 'off',
|
|
83
|
+
'@typescript-eslint/no-unused-vars': [
|
|
84
|
+
'warn',
|
|
85
|
+
{
|
|
86
|
+
args: 'none',
|
|
87
|
+
ignoreRestSiblings: true,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
'no-useless-constructor': 'off',
|
|
91
|
+
'@typescript-eslint/no-useless-constructor': 'warn',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// NOTE: When adding rules here, you need to make sure they are compatible with
|
|
96
|
+
// `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.
|
|
55
97
|
rules: {
|
|
56
98
|
// http://eslint.org/docs/rules/
|
|
57
99
|
'array-callback-return': 'warn',
|
|
@@ -161,6 +203,7 @@ module.exports = {
|
|
|
161
203
|
],
|
|
162
204
|
'no-with': 'warn',
|
|
163
205
|
'no-whitespace-before-property': 'warn',
|
|
206
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
164
207
|
'require-yield': 'warn',
|
|
165
208
|
'rest-spread-spacing': ['warn', 'never'],
|
|
166
209
|
strict: ['warn', 'never'],
|
|
@@ -241,6 +284,9 @@ module.exports = {
|
|
|
241
284
|
'jsx-a11y/role-supports-aria-props': 'warn',
|
|
242
285
|
'jsx-a11y/scope': 'warn',
|
|
243
286
|
|
|
287
|
+
// https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
|
|
288
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
289
|
+
|
|
244
290
|
// https://github.com/gajus/eslint-plugin-flowtype
|
|
245
291
|
'flowtype/define-flow-type': 'warn',
|
|
246
292
|
'flowtype/require-valid-file-annotation': 'warn',
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-react-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "ESLint configuration used by Create React App",
|
|
5
|
-
"repository":
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/facebook/create-react-app.git",
|
|
8
|
+
"directory": "packages/eslint-config-react-app"
|
|
9
|
+
},
|
|
6
10
|
"license": "MIT",
|
|
7
11
|
"bugs": {
|
|
8
12
|
"url": "https://github.com/facebook/create-react-app/issues"
|
|
@@ -11,14 +15,17 @@
|
|
|
11
15
|
"index.js"
|
|
12
16
|
],
|
|
13
17
|
"peerDependencies": {
|
|
14
|
-
"
|
|
18
|
+
"@typescript-eslint/eslint-plugin": "1.x",
|
|
19
|
+
"@typescript-eslint/parser": "1.x",
|
|
20
|
+
"babel-eslint": "10.x",
|
|
15
21
|
"eslint": "5.x",
|
|
16
22
|
"eslint-plugin-flowtype": "2.x",
|
|
17
23
|
"eslint-plugin-import": "2.x",
|
|
18
24
|
"eslint-plugin-jsx-a11y": "6.x",
|
|
19
|
-
"eslint-plugin-react": "7.x"
|
|
25
|
+
"eslint-plugin-react": "7.x",
|
|
26
|
+
"eslint-plugin-react-hooks": "1.x"
|
|
20
27
|
},
|
|
21
28
|
"dependencies": {
|
|
22
|
-
"confusing-browser-globals": "^1.0.
|
|
29
|
+
"confusing-browser-globals": "^1.0.7"
|
|
23
30
|
}
|
|
24
31
|
}
|