eslint-config-react-app 6.0.0-next.64 → 6.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/README.md +19 -2
- package/base.js +47 -0
- package/index.js +7 -35
- package/jest.js +46 -0
- package/package.json +20 -8
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 @typescript-eslint/eslint-plugin
|
|
22
|
+
npm install --save-dev eslint-config-react-app @typescript-eslint/eslint-plugin@^4.0.0 @typescript-eslint/parser@^4.0.0 babel-eslint@^10.0.0 eslint@^7.5.0 eslint-plugin-flowtype@^5.2.0 eslint-plugin-import@^2.22.0 eslint-plugin-jsx-a11y@^6.3.1 eslint-plugin-react@^7.20.3 eslint-plugin-react-hooks@^4.0.8
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Then create a file named `.eslintrc.json` with following contents in the root folder of your project:
|
|
@@ -32,11 +32,28 @@ Then create a file named `.eslintrc.json` with following contents in the root fo
|
|
|
32
32
|
|
|
33
33
|
That's it! You can override the settings from `eslint-config-react-app` by editing the `.eslintrc.json` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
|
|
34
34
|
|
|
35
|
+
## Jest rules
|
|
36
|
+
|
|
37
|
+
This config also ships with optional Jest rules for ESLint (based on [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest)).
|
|
38
|
+
|
|
39
|
+
You'll first need to add the ESLint plugin for Jest (if you don't already have it installed).
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install --save-dev eslint-plugin-jest@^24.0.0 eslint-plugin-testing-library&^3.9.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You can then enable these rules by adding the Jest config to the `extends` array in your ESLint config.
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"extends": ["react-app", "react-app/jest"]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
35
53
|
## Accessibility Checks
|
|
36
54
|
|
|
37
55
|
The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) plugin are activated:
|
|
38
56
|
|
|
39
|
-
- [accessible-emoji](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md)
|
|
40
57
|
- [alt-text](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md)
|
|
41
58
|
- [anchor-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md)
|
|
42
59
|
- [aria-activedescendant-has-tabindex](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md)
|
package/base.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
// This file contains the minimum ESLint configuration required for Create
|
|
11
|
+
// React App support, and is used as the `baseConfig` for `eslint-loader`
|
|
12
|
+
// to ensure that user-provided configs don't need this boilerplate.
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
root: true,
|
|
16
|
+
|
|
17
|
+
parser: 'babel-eslint',
|
|
18
|
+
|
|
19
|
+
plugins: ['react'],
|
|
20
|
+
|
|
21
|
+
env: {
|
|
22
|
+
browser: true,
|
|
23
|
+
commonjs: true,
|
|
24
|
+
es6: true,
|
|
25
|
+
jest: true,
|
|
26
|
+
node: true,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
parserOptions: {
|
|
30
|
+
ecmaVersion: 2018,
|
|
31
|
+
sourceType: 'module',
|
|
32
|
+
ecmaFeatures: {
|
|
33
|
+
jsx: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
settings: {
|
|
38
|
+
react: {
|
|
39
|
+
version: 'detect',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
rules: {
|
|
44
|
+
'react/jsx-uses-vars': 'warn',
|
|
45
|
+
'react/jsx-uses-react': 'warn',
|
|
46
|
+
},
|
|
47
|
+
};
|
package/index.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// Inspired by https://github.com/airbnb/javascript but less opinionated.
|
|
11
11
|
|
|
12
12
|
// We use eslint-loader so even warnings are very visible.
|
|
13
|
-
// This is why we
|
|
14
|
-
// and we
|
|
13
|
+
// This is why we prefer to use "WARNING" level for potential errors,
|
|
14
|
+
// and we try not to use "ERROR" level at all.
|
|
15
15
|
|
|
16
16
|
// In the future, we might create a separate list of rules for production.
|
|
17
17
|
// It would probably be more strict.
|
|
@@ -24,33 +24,9 @@
|
|
|
24
24
|
const restrictedGlobals = require('confusing-browser-globals');
|
|
25
25
|
|
|
26
26
|
module.exports = {
|
|
27
|
-
|
|
27
|
+
extends: [require.resolve('./base')],
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
plugins: ['import', 'flowtype', 'jsx-a11y', 'react', 'react-hooks'],
|
|
32
|
-
|
|
33
|
-
env: {
|
|
34
|
-
browser: true,
|
|
35
|
-
commonjs: true,
|
|
36
|
-
es6: true,
|
|
37
|
-
jest: true,
|
|
38
|
-
node: true,
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
parserOptions: {
|
|
42
|
-
ecmaVersion: 2018,
|
|
43
|
-
sourceType: 'module',
|
|
44
|
-
ecmaFeatures: {
|
|
45
|
-
jsx: true,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
settings: {
|
|
50
|
-
react: {
|
|
51
|
-
version: 'detect',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
29
|
+
plugins: ['import', 'flowtype', 'jsx-a11y', 'react-hooks'],
|
|
54
30
|
|
|
55
31
|
overrides: [
|
|
56
32
|
{
|
|
@@ -81,6 +57,8 @@ module.exports = {
|
|
|
81
57
|
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
82
58
|
'no-array-constructor': 'off',
|
|
83
59
|
'@typescript-eslint/no-array-constructor': 'warn',
|
|
60
|
+
'no-redeclare': 'off',
|
|
61
|
+
'@typescript-eslint/no-redeclare': 'warn',
|
|
84
62
|
'no-use-before-define': 'off',
|
|
85
63
|
'@typescript-eslint/no-use-before-define': [
|
|
86
64
|
'warn',
|
|
@@ -171,9 +149,7 @@ module.exports = {
|
|
|
171
149
|
'no-obj-calls': 'warn',
|
|
172
150
|
'no-octal': 'warn',
|
|
173
151
|
'no-octal-escape': 'warn',
|
|
174
|
-
|
|
175
|
-
// https://eslint.org/docs/user-guide/migrating-to-6.0.0#-the-no-redeclare-rule-is-now-more-strict-by-default
|
|
176
|
-
'no-redeclare': ['warn', { builtinGlobals: false }],
|
|
152
|
+
'no-redeclare': 'warn',
|
|
177
153
|
'no-regex-spaces': 'warn',
|
|
178
154
|
'no-restricted-syntax': ['warn', 'WithStatement'],
|
|
179
155
|
'no-script-url': 'warn',
|
|
@@ -269,8 +245,6 @@ module.exports = {
|
|
|
269
245
|
ignore: [],
|
|
270
246
|
},
|
|
271
247
|
],
|
|
272
|
-
'react/jsx-uses-react': 'warn',
|
|
273
|
-
'react/jsx-uses-vars': 'warn',
|
|
274
248
|
'react/no-danger-with-children': 'warn',
|
|
275
249
|
// Disabled because of undesirable warnings
|
|
276
250
|
// See https://github.com/facebook/create-react-app/issues/5204 for
|
|
@@ -279,12 +253,10 @@ module.exports = {
|
|
|
279
253
|
'react/no-direct-mutation-state': 'warn',
|
|
280
254
|
'react/no-is-mounted': 'warn',
|
|
281
255
|
'react/no-typos': 'error',
|
|
282
|
-
'react/react-in-jsx-scope': 'error',
|
|
283
256
|
'react/require-render-return': 'error',
|
|
284
257
|
'react/style-prop-object': 'warn',
|
|
285
258
|
|
|
286
259
|
// https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
|
|
287
|
-
'jsx-a11y/accessible-emoji': 'warn',
|
|
288
260
|
'jsx-a11y/alt-text': 'warn',
|
|
289
261
|
'jsx-a11y/anchor-has-content': 'warn',
|
|
290
262
|
'jsx-a11y/anchor-is-valid': [
|
package/jest.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
// We use eslint-loader so even warnings are very visible.
|
|
11
|
+
// This is why we prefer to use "WARNING" level for potential errors,
|
|
12
|
+
// and we try not to use "ERROR" level at all.
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
plugins: ['jest', 'testing-library'],
|
|
16
|
+
overrides: [
|
|
17
|
+
{
|
|
18
|
+
files: ['**/__tests__/**/*', '**/*.{spec,test}.*'],
|
|
19
|
+
env: {
|
|
20
|
+
'jest/globals': true,
|
|
21
|
+
},
|
|
22
|
+
// A subset of the recommended rules:
|
|
23
|
+
rules: {
|
|
24
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
25
|
+
'jest/no-conditional-expect': 'error',
|
|
26
|
+
'jest/no-identical-title': 'error',
|
|
27
|
+
'jest/no-interpolation-in-snapshots': 'error',
|
|
28
|
+
'jest/no-jasmine-globals': 'error',
|
|
29
|
+
'jest/no-jest-import': 'error',
|
|
30
|
+
'jest/no-mocks-import': 'error',
|
|
31
|
+
'jest/valid-describe': 'error',
|
|
32
|
+
'jest/valid-expect': 'error',
|
|
33
|
+
'jest/valid-expect-in-promise': 'error',
|
|
34
|
+
'jest/valid-title': 'warn',
|
|
35
|
+
|
|
36
|
+
// https://github.com/testing-library/eslint-plugin-testing-library
|
|
37
|
+
'testing-library/await-async-query': 'error',
|
|
38
|
+
'testing-library/await-async-utils': 'error',
|
|
39
|
+
'testing-library/no-await-sync-query': 'warn',
|
|
40
|
+
'testing-library/no-dom-import': ['error', 'react'],
|
|
41
|
+
'testing-library/no-wait-for-empty-callback': 'error',
|
|
42
|
+
'testing-library/no-wait-for-snapshot': 'error',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-react-app",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "ESLint configuration used by Create React App",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,24 +12,36 @@
|
|
|
12
12
|
"url": "https://github.com/facebook/create-react-app/issues"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"
|
|
15
|
+
"base.js",
|
|
16
|
+
"index.js",
|
|
17
|
+
"jest.js"
|
|
16
18
|
],
|
|
17
19
|
"peerDependencies": {
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
19
|
-
"@typescript-eslint/parser": "^
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
|
21
|
+
"@typescript-eslint/parser": "^4.0.0",
|
|
20
22
|
"babel-eslint": "^10.0.0",
|
|
21
|
-
"eslint": "^7.
|
|
23
|
+
"eslint": "^7.5.0",
|
|
22
24
|
"eslint-plugin-flowtype": "^5.2.0",
|
|
23
25
|
"eslint-plugin-import": "^2.22.0",
|
|
26
|
+
"eslint-plugin-jest": "^24.0.0",
|
|
24
27
|
"eslint-plugin-jsx-a11y": "^6.3.1",
|
|
25
28
|
"eslint-plugin-react": "^7.20.3",
|
|
26
|
-
"eslint-plugin-react-hooks": "^4.0.8"
|
|
29
|
+
"eslint-plugin-react-hooks": "^4.0.8",
|
|
30
|
+
"eslint-plugin-testing-library": "^3.9.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"eslint-plugin-jest": {
|
|
34
|
+
"optional": true
|
|
35
|
+
},
|
|
36
|
+
"eslint-plugin-testing-library": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
27
39
|
},
|
|
28
40
|
"dependencies": {
|
|
29
|
-
"confusing-browser-globals": "
|
|
41
|
+
"confusing-browser-globals": "^1.0.10"
|
|
30
42
|
},
|
|
31
43
|
"engines": {
|
|
32
44
|
"node": "^10.12.0 || >=12.0.0"
|
|
33
45
|
},
|
|
34
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "ed958938f642007645dd5ac3466db36202f8754e"
|
|
35
47
|
}
|