eslint-config-react-app-new 0.0.4 → 2.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 +17 -71
- package/base.js +27 -54
- package/index.js +207 -287
- package/jest.js +53 -58
- package/package.json +18 -23
package/README.md
CHANGED
|
@@ -1,78 +1,24 @@
|
|
|
1
|
-
# eslint-config-react-app
|
|
1
|
+
# eslint-config-react-app-new
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Please refer to its documentation:
|
|
3
|
+
## Requirements
|
|
5
4
|
|
|
6
|
-
-
|
|
7
|
-
-
|
|
5
|
+
- `Node.js >= 18.20.0`
|
|
6
|
+
- `ESLint >= 9.0.0`
|
|
8
7
|
|
|
9
|
-
## Usage
|
|
8
|
+
## Usage
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
```js
|
|
11
|
+
// eslint.config.js
|
|
12
|
+
const { defineConfig } = require('eslint/config');
|
|
13
|
+
const reactAppConfig = require('eslint-config-react-app-new');
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
module.exports = defineConfig({
|
|
16
|
+
extends: [reactAppConfig],
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
npm install --save-dev eslint-config-react-app eslint@^8.0.0
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Then create a file named `.eslintrc.json` with following contents in the root folder of your project:
|
|
26
|
-
|
|
27
|
-
```json
|
|
28
|
-
{
|
|
29
|
-
"extends": "react-app"
|
|
30
|
-
}
|
|
18
|
+
// Optional: other custom rules can be added here
|
|
19
|
+
rules: {
|
|
20
|
+
// example: override a rule
|
|
21
|
+
'no-console': 'warn'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
31
24
|
```
|
|
32
|
-
|
|
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](https://eslint.org/docs/user-guide/configuring) on the ESLint website.
|
|
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 can enable these rules by adding the Jest config to the `extends` array in your ESLint config.
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"extends": ["react-app", "react-app/jest"]
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Accessibility Checks
|
|
48
|
-
|
|
49
|
-
The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) plugin are activated:
|
|
50
|
-
|
|
51
|
-
- [alt-text](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md)
|
|
52
|
-
- [anchor-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md)
|
|
53
|
-
- [aria-activedescendant-has-tabindex](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md)
|
|
54
|
-
- [aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md)
|
|
55
|
-
- [aria-proptypes](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md)
|
|
56
|
-
- [aria-role](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md)
|
|
57
|
-
- [aria-unsupported-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md)
|
|
58
|
-
- [heading-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md)
|
|
59
|
-
- [href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/v5.1.1/docs/rules/href-no-hash.md)
|
|
60
|
-
- [iframe-has-title](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md)
|
|
61
|
-
- [img-redundant-alt](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md)
|
|
62
|
-
- [no-access-key](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md)
|
|
63
|
-
- [no-distracting-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md)
|
|
64
|
-
- [no-redundant-roles](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md)
|
|
65
|
-
- [role-has-required-aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md)
|
|
66
|
-
- [role-supports-aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md)
|
|
67
|
-
- [scope](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md)
|
|
68
|
-
|
|
69
|
-
If you want to enable even more accessibility rules, you can create an `.eslintrc.json` file in the root of your project with this content:
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"extends": ["react-app", "plugin:jsx-a11y/recommended"],
|
|
74
|
-
"plugins": ["jsx-a11y"]
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
However, if you are using [Create React App](https://github.com/facebook/create-react-app) and have not ejected, any additional rules will only be displayed in the [IDE integrations](https://facebook.github.io/create-react-app/docs/setting-up-your-editor#displaying-lint-output-in-the-editor), but not in the browser or the terminal.
|
package/base.js
CHANGED
|
@@ -1,56 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
node: true
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
parserOptions: {
|
|
31
|
-
sourceType: 'module',
|
|
32
|
-
requireConfigFile: false,
|
|
33
|
-
babelOptions: {
|
|
34
|
-
presets: [require.resolve('babel-preset-react-app-new/prod')],
|
|
35
|
-
plugins: [
|
|
36
|
-
[
|
|
37
|
-
'@babel/plugin-proposal-decorators',
|
|
38
|
-
{
|
|
39
|
-
legacy: true
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
]
|
|
1
|
+
const react = require('eslint-plugin-react');
|
|
2
|
+
const babelParser = require('@babel/eslint-parser');
|
|
3
|
+
const globals = require('globals');
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
{
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: babelParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
requireConfigFile: false,
|
|
12
|
+
babelOptions: {
|
|
13
|
+
presets: [require.resolve('babel-preset-react-app-new/prod')]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
// true means writeable, false means readonly, 'off' means disabled
|
|
17
|
+
gloabls: {
|
|
18
|
+
...globals.browser,
|
|
19
|
+
...globals.node,
|
|
20
|
+
...globals.commonjs,
|
|
21
|
+
...globals.es2018,
|
|
22
|
+
__: 'readonly',
|
|
23
|
+
__SSR__: 'readonly',
|
|
24
|
+
__DEV__: 'readonly',
|
|
25
|
+
__LOCAL_DEV__: 'readonly'
|
|
26
|
+
}
|
|
43
27
|
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
settings: {
|
|
47
|
-
react: {
|
|
48
|
-
version: 'detect'
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
rules: {
|
|
53
|
-
'react/jsx-uses-vars': 'warn',
|
|
54
|
-
'react/jsx-uses-react': 'warn'
|
|
55
28
|
}
|
|
56
|
-
|
|
29
|
+
];
|
package/index.js
CHANGED
|
@@ -1,291 +1,211 @@
|
|
|
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
|
-
// Inspired by https://github.com/airbnb/javascript but less opinionated.
|
|
11
|
-
|
|
12
|
-
// We use eslint-loader so even warnings are very visible.
|
|
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
|
-
|
|
16
|
-
// In the future, we might create a separate list of rules for production.
|
|
17
|
-
// It would probably be more strict.
|
|
18
|
-
|
|
19
|
-
// The ESLint browser environment defines all browser globals as valid,
|
|
20
|
-
// even though most people don't know some of them exist (e.g. `name` or `status`).
|
|
21
|
-
// This is dangerous as it hides accidentally undefined variables.
|
|
22
|
-
// We blacklist the globals that we deem potentially confusing.
|
|
23
|
-
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
|
|
24
1
|
const restrictedGlobals = require('confusing-browser-globals');
|
|
2
|
+
const tseslint = require('typescript-eslint');
|
|
3
|
+
const baseConfig = require('./base');
|
|
4
|
+
const reactConfig = require('./react');
|
|
5
|
+
const jsxA11yConfig = require('./jsx-a11y');
|
|
6
|
+
const importConfig = require('./import');
|
|
25
7
|
|
|
26
|
-
module.exports =
|
|
27
|
-
extends: [require.resolve('./base')],
|
|
28
|
-
|
|
29
|
-
plugins: ['import', 'flowtype', 'jsx-a11y', 'react-hooks'],
|
|
30
|
-
|
|
31
|
-
overrides: [
|
|
8
|
+
module.exports = [
|
|
32
9
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
rules: {
|
|
14
|
+
// http://eslint.org/docs/rules/
|
|
15
|
+
'array-callback-return': 'warn',
|
|
16
|
+
'default-case': ['warn', { commentPattern: '^no default$' }],
|
|
17
|
+
'dot-location': ['warn', 'property'],
|
|
18
|
+
eqeqeq: ['warn', 'smart'],
|
|
19
|
+
'new-parens': 'warn',
|
|
20
|
+
'no-array-constructor': 'warn',
|
|
21
|
+
'no-caller': 'warn',
|
|
22
|
+
'no-cond-assign': ['warn', 'except-parens'],
|
|
23
|
+
'no-const-assign': 'warn',
|
|
24
|
+
'no-constructor-return': ['error'],
|
|
25
|
+
'no-control-regex': 'warn',
|
|
26
|
+
'no-delete-var': 'warn',
|
|
27
|
+
'no-dupe-args': 'warn',
|
|
28
|
+
'no-dupe-class-members': 'warn',
|
|
29
|
+
'no-dupe-keys': 'warn',
|
|
30
|
+
'no-duplicate-case': 'warn',
|
|
31
|
+
'no-empty-character-class': 'warn',
|
|
32
|
+
'no-empty-pattern': 'warn',
|
|
33
|
+
'no-eval': 'warn',
|
|
34
|
+
'no-ex-assign': 'warn',
|
|
35
|
+
'no-extend-native': 'warn',
|
|
36
|
+
'no-extra-bind': 'warn',
|
|
37
|
+
'no-extra-label': 'warn',
|
|
38
|
+
'no-fallthrough': 'warn',
|
|
39
|
+
'no-func-assign': 'warn',
|
|
40
|
+
'no-implied-eval': 'warn',
|
|
41
|
+
'no-invalid-regexp': 'warn',
|
|
42
|
+
'no-iterator': 'warn',
|
|
43
|
+
'no-label-var': 'warn',
|
|
44
|
+
'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
|
|
45
|
+
'no-lone-blocks': 'warn',
|
|
46
|
+
'no-loop-func': 'warn',
|
|
47
|
+
'no-mixed-operators': [
|
|
48
|
+
'warn',
|
|
49
|
+
{
|
|
50
|
+
groups: [
|
|
51
|
+
['&', '|', '^', '~', '<<', '>>', '>>>'],
|
|
52
|
+
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
|
53
|
+
['&&', '||'],
|
|
54
|
+
['in', 'instanceof']
|
|
55
|
+
],
|
|
56
|
+
allowSamePrecedence: false
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
'no-multi-str': 'warn',
|
|
60
|
+
'no-global-assign': 'warn',
|
|
61
|
+
'no-unsafe-negation': 'warn',
|
|
62
|
+
'no-new-func': 'warn',
|
|
63
|
+
'no-new-object': 'warn',
|
|
64
|
+
'no-new-symbol': 'warn',
|
|
65
|
+
'no-new-wrappers': 'warn',
|
|
66
|
+
'no-obj-calls': 'warn',
|
|
67
|
+
'no-octal': 'warn',
|
|
68
|
+
'no-octal-escape': 'warn',
|
|
69
|
+
'no-redeclare': 'warn',
|
|
70
|
+
'no-regex-spaces': 'warn',
|
|
71
|
+
'no-restricted-syntax': ['warn', 'WithStatement'],
|
|
72
|
+
'no-script-url': 'warn',
|
|
73
|
+
'no-self-assign': 'warn',
|
|
74
|
+
'no-self-compare': 'warn',
|
|
75
|
+
'no-sequences': 'warn',
|
|
76
|
+
'no-shadow-restricted-names': 'warn',
|
|
77
|
+
'no-sparse-arrays': 'warn',
|
|
78
|
+
'no-template-curly-in-string': 'warn',
|
|
79
|
+
'no-this-before-super': 'warn',
|
|
80
|
+
'no-throw-literal': 'warn',
|
|
81
|
+
'no-undef': 'error',
|
|
82
|
+
'no-restricted-globals': ['error'].concat(restrictedGlobals),
|
|
83
|
+
'no-unreachable': 'warn',
|
|
84
|
+
'no-unused-expressions': [
|
|
85
|
+
'error',
|
|
86
|
+
{
|
|
87
|
+
allowShortCircuit: true,
|
|
88
|
+
allowTernary: true,
|
|
89
|
+
allowTaggedTemplates: true
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
'no-unused-labels': 'warn',
|
|
93
|
+
'no-unused-vars': [
|
|
94
|
+
'warn',
|
|
95
|
+
{
|
|
96
|
+
args: 'none',
|
|
97
|
+
ignoreRestSiblings: true
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
'no-use-before-define': [
|
|
101
|
+
'warn',
|
|
102
|
+
{
|
|
103
|
+
functions: false,
|
|
104
|
+
classes: false,
|
|
105
|
+
variables: false
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
'no-useless-computed-key': 'warn',
|
|
109
|
+
'no-useless-concat': 'warn',
|
|
110
|
+
'no-useless-constructor': 'warn',
|
|
111
|
+
'no-useless-escape': 'warn',
|
|
112
|
+
'no-useless-rename': [
|
|
113
|
+
'warn',
|
|
114
|
+
{
|
|
115
|
+
ignoreDestructuring: false,
|
|
116
|
+
ignoreImport: false,
|
|
117
|
+
ignoreExport: false
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
'no-with': 'warn',
|
|
121
|
+
'no-whitespace-before-property': 'warn',
|
|
122
|
+
'require-yield': 'warn',
|
|
123
|
+
'rest-spread-spacing': ['warn', 'never'],
|
|
124
|
+
strict: ['warn', 'never'],
|
|
125
|
+
'unicode-bom': ['warn', 'never'],
|
|
126
|
+
'use-isnan': 'warn',
|
|
127
|
+
'valid-typeof': 'warn',
|
|
128
|
+
|
|
129
|
+
'no-restricted-properties': [
|
|
130
|
+
'error',
|
|
131
|
+
{
|
|
132
|
+
object: 'require',
|
|
133
|
+
property: 'ensure',
|
|
134
|
+
message:
|
|
135
|
+
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting'
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
object: 'System',
|
|
139
|
+
property: 'import',
|
|
140
|
+
message:
|
|
141
|
+
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting'
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
'getter-return': 'warn'
|
|
145
|
+
}
|
|
92
146
|
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
'no-sequences': 'warn',
|
|
159
|
-
'no-shadow-restricted-names': 'warn',
|
|
160
|
-
'no-sparse-arrays': 'warn',
|
|
161
|
-
'no-template-curly-in-string': 'warn',
|
|
162
|
-
'no-this-before-super': 'warn',
|
|
163
|
-
'no-throw-literal': 'warn',
|
|
164
|
-
'no-undef': 'error',
|
|
165
|
-
'no-restricted-globals': ['error'].concat(restrictedGlobals),
|
|
166
|
-
'no-unreachable': 'warn',
|
|
167
|
-
'no-unused-expressions': [
|
|
168
|
-
'error',
|
|
169
|
-
{
|
|
170
|
-
allowShortCircuit: true,
|
|
171
|
-
allowTernary: true,
|
|
172
|
-
allowTaggedTemplates: true,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
'no-unused-labels': 'warn',
|
|
176
|
-
'no-unused-vars': [
|
|
177
|
-
'warn',
|
|
178
|
-
{
|
|
179
|
-
args: 'none',
|
|
180
|
-
ignoreRestSiblings: true,
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
'no-use-before-define': [
|
|
184
|
-
'warn',
|
|
185
|
-
{
|
|
186
|
-
functions: false,
|
|
187
|
-
classes: false,
|
|
188
|
-
variables: false,
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
'no-useless-computed-key': 'warn',
|
|
192
|
-
'no-useless-concat': 'warn',
|
|
193
|
-
'no-useless-constructor': 'warn',
|
|
194
|
-
'no-useless-escape': 'warn',
|
|
195
|
-
'no-useless-rename': [
|
|
196
|
-
'warn',
|
|
197
|
-
{
|
|
198
|
-
ignoreDestructuring: false,
|
|
199
|
-
ignoreImport: false,
|
|
200
|
-
ignoreExport: false,
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
'no-with': 'warn',
|
|
204
|
-
'no-whitespace-before-property': 'warn',
|
|
205
|
-
'react-hooks/exhaustive-deps': 'warn',
|
|
206
|
-
'require-yield': 'warn',
|
|
207
|
-
'rest-spread-spacing': ['warn', 'never'],
|
|
208
|
-
strict: ['warn', 'never'],
|
|
209
|
-
'unicode-bom': ['warn', 'never'],
|
|
210
|
-
'use-isnan': 'warn',
|
|
211
|
-
'valid-typeof': 'warn',
|
|
212
|
-
'no-restricted-properties': [
|
|
213
|
-
'error',
|
|
214
|
-
{
|
|
215
|
-
object: 'require',
|
|
216
|
-
property: 'ensure',
|
|
217
|
-
message:
|
|
218
|
-
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
object: 'System',
|
|
222
|
-
property: 'import',
|
|
223
|
-
message:
|
|
224
|
-
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
'getter-return': 'warn',
|
|
228
|
-
|
|
229
|
-
// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
|
|
230
|
-
'import/first': 'error',
|
|
231
|
-
'import/no-amd': 'error',
|
|
232
|
-
'import/no-anonymous-default-export': 'warn',
|
|
233
|
-
'import/no-webpack-loader-syntax': 'error',
|
|
234
|
-
|
|
235
|
-
// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
|
|
236
|
-
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
|
|
237
|
-
'react/jsx-no-comment-textnodes': 'warn',
|
|
238
|
-
'react/jsx-no-duplicate-props': 'warn',
|
|
239
|
-
'react/jsx-no-target-blank': 'warn',
|
|
240
|
-
'react/jsx-no-undef': 'error',
|
|
241
|
-
'react/jsx-pascal-case': [
|
|
242
|
-
'warn',
|
|
243
|
-
{
|
|
244
|
-
allowAllCaps: true,
|
|
245
|
-
ignore: [],
|
|
246
|
-
},
|
|
247
|
-
],
|
|
248
|
-
'react/no-danger-with-children': 'warn',
|
|
249
|
-
// Disabled because of undesirable warnings
|
|
250
|
-
// See https://github.com/facebook/create-react-app/issues/5204 for
|
|
251
|
-
// blockers until its re-enabled
|
|
252
|
-
// 'react/no-deprecated': 'warn',
|
|
253
|
-
'react/no-direct-mutation-state': 'warn',
|
|
254
|
-
'react/no-is-mounted': 'warn',
|
|
255
|
-
'react/no-typos': 'error',
|
|
256
|
-
'react/require-render-return': 'error',
|
|
257
|
-
'react/style-prop-object': 'warn',
|
|
258
|
-
|
|
259
|
-
// https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
|
|
260
|
-
'jsx-a11y/alt-text': 'warn',
|
|
261
|
-
'jsx-a11y/anchor-has-content': 'warn',
|
|
262
|
-
'jsx-a11y/anchor-is-valid': [
|
|
263
|
-
'warn',
|
|
264
|
-
{
|
|
265
|
-
aspects: ['noHref', 'invalidHref'],
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
|
|
269
|
-
'jsx-a11y/aria-props': 'warn',
|
|
270
|
-
'jsx-a11y/aria-proptypes': 'warn',
|
|
271
|
-
'jsx-a11y/aria-role': ['warn', { ignoreNonDOM: true }],
|
|
272
|
-
'jsx-a11y/aria-unsupported-elements': 'warn',
|
|
273
|
-
'jsx-a11y/heading-has-content': 'warn',
|
|
274
|
-
'jsx-a11y/iframe-has-title': 'warn',
|
|
275
|
-
'jsx-a11y/img-redundant-alt': 'warn',
|
|
276
|
-
'jsx-a11y/no-access-key': 'warn',
|
|
277
|
-
'jsx-a11y/no-distracting-elements': 'warn',
|
|
278
|
-
'jsx-a11y/no-redundant-roles': 'warn',
|
|
279
|
-
'jsx-a11y/role-has-required-aria-props': 'warn',
|
|
280
|
-
'jsx-a11y/role-supports-aria-props': 'warn',
|
|
281
|
-
'jsx-a11y/scope': 'warn',
|
|
282
|
-
|
|
283
|
-
// https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
|
|
284
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
285
|
-
|
|
286
|
-
// https://github.com/gajus/eslint-plugin-flowtype
|
|
287
|
-
'flowtype/define-flow-type': 'warn',
|
|
288
|
-
'flowtype/require-valid-file-annotation': 'warn',
|
|
289
|
-
'flowtype/use-flow-type': 'warn',
|
|
290
|
-
},
|
|
291
|
-
};
|
|
147
|
+
{
|
|
148
|
+
files: ['app/**/*'],
|
|
149
|
+
rules: {
|
|
150
|
+
'no-console': 'warn'
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
155
|
+
plugins: {
|
|
156
|
+
'@typescript-eslint': tseslint
|
|
157
|
+
},
|
|
158
|
+
extends: ['@typescript-eslint/eslint-recommended'],
|
|
159
|
+
languageOptions: {
|
|
160
|
+
parser: tseslint.parser,
|
|
161
|
+
sourceType: 'module',
|
|
162
|
+
parserOptions: {
|
|
163
|
+
ecmaVersion: 2018,
|
|
164
|
+
ecmaFeatures: {
|
|
165
|
+
jsx: true
|
|
166
|
+
},
|
|
167
|
+
projectService: false,
|
|
168
|
+
experimentalDecorators: true,
|
|
169
|
+
warnOnUnsupportedTypeScriptVersion: false
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
rules: {
|
|
173
|
+
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
|
|
174
|
+
'default-case': 'off',
|
|
175
|
+
// Add TypeScript specific rules (and turn off ESLint equivalents)
|
|
176
|
+
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
177
|
+
'no-array-constructor': 'off',
|
|
178
|
+
'@typescript-eslint/no-array-constructor': 'warn',
|
|
179
|
+
'@typescript-eslint/no-redeclare': 'warn',
|
|
180
|
+
'no-use-before-define': 'off',
|
|
181
|
+
'@typescript-eslint/no-use-before-define': [
|
|
182
|
+
'warn',
|
|
183
|
+
{
|
|
184
|
+
functions: false,
|
|
185
|
+
classes: false,
|
|
186
|
+
variables: false,
|
|
187
|
+
typedefs: false
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
'no-unused-expressions': 'off',
|
|
191
|
+
'@typescript-eslint/no-unused-expressions': [
|
|
192
|
+
'error',
|
|
193
|
+
{
|
|
194
|
+
allowShortCircuit: true,
|
|
195
|
+
allowTernary: true,
|
|
196
|
+
allowTaggedTemplates: true
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
'no-unused-vars': 'off',
|
|
200
|
+
'@typescript-eslint/no-unused-vars': [
|
|
201
|
+
'warn',
|
|
202
|
+
{
|
|
203
|
+
args: 'none',
|
|
204
|
+
ignoreRestSiblings: true
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
'no-useless-constructor': 'off',
|
|
208
|
+
'@typescript-eslint/no-useless-constructor': 'warn'
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
];
|
package/jest.js
CHANGED
|
@@ -1,61 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
*/
|
|
1
|
+
const jestPlugin = require('eslint-plugin-jest');
|
|
2
|
+
const testingLibraryPlugin = require('eslint-plugin-testing-library');
|
|
3
|
+
const globals = require('globals');
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
|
|
11
|
-
require('@rushstack/eslint-patch/modern-module-resolution');
|
|
12
|
-
|
|
13
|
-
// We use eslint-loader so even warnings are very visible.
|
|
14
|
-
// This is why we prefer to use "WARNING" level for potential errors,
|
|
15
|
-
// and we try not to use "ERROR" level at all.
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
plugins: ['jest', 'testing-library'],
|
|
19
|
-
overrides: [
|
|
5
|
+
module.exports = [
|
|
20
6
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
7
|
+
files: ['**/__tests__/**/*', '**/*.{spec,test}.*'],
|
|
8
|
+
languageOptions: {
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.jest
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
plugins: {
|
|
14
|
+
jest: jestPlugin,
|
|
15
|
+
'testing-library': testingLibraryPlugin
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
'no-console': 'off',
|
|
19
|
+
|
|
20
|
+
'jest/consistent-test-it': ['warn', { fn: 'test' }],
|
|
21
|
+
'jest/expect-expect': 'warn',
|
|
22
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
23
|
+
'jest/no-conditional-expect': 'error',
|
|
24
|
+
'jest/no-deprecated-functions': 'error',
|
|
25
|
+
'jest/no-identical-title': 'error',
|
|
26
|
+
'jest/no-interpolation-in-snapshots': 'error',
|
|
27
|
+
'jest/no-jasmine-globals': 'error',
|
|
28
|
+
'jest/no-mocks-import': 'error',
|
|
29
|
+
'jest/valid-describe-callback': 'error',
|
|
30
|
+
'jest/valid-expect': 'error',
|
|
31
|
+
'jest/valid-expect-in-promise': 'error',
|
|
32
|
+
'jest/valid-title': 'warn',
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
};
|
|
34
|
+
// https://github.com/testing-library/eslint-plugin-testing-library
|
|
35
|
+
'testing-library/await-async-query': 'error',
|
|
36
|
+
'testing-library/await-async-utils': 'error',
|
|
37
|
+
'testing-library/no-await-sync-query': 'error',
|
|
38
|
+
'testing-library/no-container': 'error',
|
|
39
|
+
'testing-library/no-debugging-utils': 'error',
|
|
40
|
+
'testing-library/no-dom-import': ['error', 'react'],
|
|
41
|
+
'testing-library/no-node-access': 'error',
|
|
42
|
+
'testing-library/no-promise-in-fire-event': 'error',
|
|
43
|
+
'testing-library/no-render-in-setup': 'error',
|
|
44
|
+
'testing-library/no-unnecessary-act': 'error',
|
|
45
|
+
'testing-library/no-wait-for-empty-callback': 'error',
|
|
46
|
+
'testing-library/no-wait-for-multiple-assertions': 'error',
|
|
47
|
+
'testing-library/no-wait-for-side-effects': 'error',
|
|
48
|
+
'testing-library/no-wait-for-snapshot': 'error',
|
|
49
|
+
'testing-library/prefer-find-by': 'error',
|
|
50
|
+
'testing-library/prefer-presence-queries': 'error',
|
|
51
|
+
'testing-library/prefer-query-by-disappearance': 'error',
|
|
52
|
+
'testing-library/prefer-screen-queries': 'error',
|
|
53
|
+
'testing-library/render-result-naming-convention': 'error'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
];
|
package/package.json
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-react-app-new",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "ESLint configuration used by
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "ESLint configuration used by tiger-new",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
8
|
-
"directory": "packages/eslint-config-react-app"
|
|
7
|
+
"url": "https://github.com/qiqiboy/tiger-new.git"
|
|
9
8
|
},
|
|
10
9
|
"license": "MIT",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/facebook/create-react-app/issues"
|
|
13
|
-
},
|
|
14
10
|
"files": [
|
|
15
11
|
"base.js",
|
|
16
12
|
"index.js",
|
|
17
13
|
"jest.js"
|
|
18
14
|
],
|
|
19
|
-
"peerDependencies": {
|
|
20
|
-
"eslint": "^8.0.0"
|
|
21
|
-
},
|
|
22
15
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.
|
|
24
|
-
"@babel/eslint-parser": "^7.
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"@typescript-eslint/parser": "^6.1.0",
|
|
28
|
-
"babel-preset-react-app-new": "^0.0.3",
|
|
16
|
+
"@babel/core": "^7.28.5",
|
|
17
|
+
"@babel/eslint-parser": "^7.28.5",
|
|
18
|
+
"@eslint/js": "^9.39.2",
|
|
19
|
+
"babel-preset-react-app-new": "^2.0.0",
|
|
29
20
|
"confusing-browser-globals": "^1.0.11",
|
|
30
|
-
"eslint-plugin-
|
|
31
|
-
"eslint-plugin-
|
|
32
|
-
"eslint-plugin-
|
|
33
|
-
"eslint-plugin-
|
|
34
|
-
"eslint-plugin-react": "^7.
|
|
35
|
-
"eslint-plugin-
|
|
36
|
-
"
|
|
21
|
+
"eslint-plugin-import": "^2.32.0",
|
|
22
|
+
"eslint-plugin-jest": "^29.12.1",
|
|
23
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
24
|
+
"eslint-plugin-react": "^7.37.5",
|
|
25
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
26
|
+
"eslint-plugin-testing-library": "^7.15.4",
|
|
27
|
+
"globals": "^17.0.0",
|
|
28
|
+
"typescript-eslint": "^8.52.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"eslint": ">= 9"
|
|
37
32
|
},
|
|
38
33
|
"engines": {
|
|
39
34
|
"node": ">=14.0.0"
|