@pplancq/eslint-config 6.1.5 → 6.2.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/CHANGELOG.md +36 -0
- package/README.md +17 -1
- package/main.js +81 -25
- package/package.json +12 -9
- package/rules/base.js +2 -2
- package/rules/import.js +269 -262
- package/rules/playwright.js +3 -2
- package/rules/prettier.js +2 -2
- package/rules/react-jsx-a11y.js +216 -218
- package/rules/react.js +604 -591
- package/rules/typescript.js +554 -548
- package/rules/utils.js +63 -0
- package/rules/vitest.js +176 -168
package/rules/react.js
CHANGED
|
@@ -2,8 +2,11 @@ import jestDom from "eslint-plugin-jest-dom";
|
|
|
2
2
|
import reactPlugin from "eslint-plugin-react";
|
|
3
3
|
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
4
4
|
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
5
|
+
/* eslint-disable import/extensions */
|
|
6
|
+
import { prefix } from "./utils.js";
|
|
7
|
+
/* eslint-enable import/extensions */
|
|
5
8
|
|
|
6
|
-
export const reactRules = {
|
|
9
|
+
export const reactRules = ({ import: importNs = "import-x" } = {}) => ({
|
|
7
10
|
plugins: {
|
|
8
11
|
react: reactPlugin,
|
|
9
12
|
"react-hooks": reactHooksPlugin,
|
|
@@ -15,629 +18,633 @@ export const reactRules = {
|
|
|
15
18
|
},
|
|
16
19
|
},
|
|
17
20
|
},
|
|
18
|
-
rules:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
rules: prefix(
|
|
22
|
+
{
|
|
23
|
+
// eslint-plugin-import-x https://github.com/un-ts/eslint-plugin-import-x
|
|
24
|
+
|
|
25
|
+
// import-x/extensions
|
|
26
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
|
|
27
|
+
"import-x/extensions": [
|
|
28
|
+
"error",
|
|
29
|
+
"ignorePackages",
|
|
30
|
+
{
|
|
31
|
+
js: "never",
|
|
32
|
+
jsx: "never",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
// eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
// Enforces consistent naming for boolean props
|
|
39
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md
|
|
40
|
+
"react/boolean-prop-naming": [
|
|
41
|
+
"off",
|
|
42
|
+
{
|
|
43
|
+
propTypeNames: ["bool", "mutuallyExclusiveTrueProps"],
|
|
44
|
+
rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+",
|
|
45
|
+
message: "",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
// Disallow usage of `button` elements without an explicit `type` attribute
|
|
50
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
51
|
+
"react/button-has-type": [
|
|
52
|
+
"error",
|
|
53
|
+
{
|
|
54
|
+
button: true,
|
|
55
|
+
submit: true,
|
|
56
|
+
reset: false,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// Enforce all `defaultProps` have a corresponding non-required `PropType`
|
|
61
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
|
|
62
|
-
"react/default-props-match-prop-types": ["error", { allowRequiredDefaults: false }],
|
|
63
|
-
|
|
64
|
-
// Enforce consistent usage of destructuring assignment of props, state, and context
|
|
65
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
|
|
66
|
-
"react/destructuring-assignment": ["error", "always"],
|
|
67
|
-
|
|
68
|
-
// Disallow missing `displayName` in a React component definition
|
|
69
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
70
|
-
"react/display-name": "error",
|
|
71
|
-
|
|
72
|
-
// Disallow certain props on components
|
|
73
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
|
|
74
|
-
"react/forbid-component-props": ["off", { forbid: [] }],
|
|
75
|
-
|
|
76
|
-
// Disallow certain props on DOM Nodes
|
|
77
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md
|
|
78
|
-
"react/forbid-dom-props": ["off", { forbid: [] }],
|
|
79
|
-
|
|
80
|
-
// Disallow certain elements
|
|
81
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
|
|
82
|
-
"react/forbid-elements": ["off", { forbid: [] }],
|
|
83
|
-
|
|
84
|
-
// Disallow using another component's `propTypes`
|
|
85
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
86
|
-
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }],
|
|
87
|
-
|
|
88
|
-
// Disallow certain `propTypes`
|
|
89
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
|
|
90
|
-
"react/forbid-prop-types": [
|
|
91
|
-
"error",
|
|
92
|
-
{
|
|
93
|
-
forbid: ["any", "array", "object"],
|
|
94
|
-
checkContextTypes: true,
|
|
95
|
-
checkChildContextTypes: true,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
60
|
+
// Enforce using `onChange` or `readonly` attribute when `checked` is used
|
|
61
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md
|
|
62
|
+
"react/checked-requires-onchange-or-readonly": "off",
|
|
98
63
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"error",
|
|
103
|
-
{
|
|
104
|
-
namedComponents: ["function-declaration", "arrow-function", "function-expression"],
|
|
105
|
-
unnamedComponents: ["arrow-function", "function-expression"],
|
|
106
|
-
},
|
|
107
|
-
],
|
|
64
|
+
// Enforce all `defaultProps` have a corresponding non-required `PropType`
|
|
65
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
|
|
66
|
+
"react/default-props-match-prop-types": ["error", { allowRequiredDefaults: false }],
|
|
108
67
|
|
|
109
|
-
|
|
110
|
-
|
|
68
|
+
// Enforce consistent usage of destructuring assignment of props, state, and context
|
|
69
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
|
|
70
|
+
"react/destructuring-assignment": ["error", "always"],
|
|
111
71
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
72
|
+
// Disallow missing `displayName` in a React component definition
|
|
73
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
74
|
+
"react/display-name": "error",
|
|
115
75
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
76
|
+
// Disallow certain props on components
|
|
77
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
|
|
78
|
+
"react/forbid-component-props": ["off", { forbid: [] }],
|
|
119
79
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
80
|
+
// Disallow certain props on DOM Nodes
|
|
81
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md
|
|
82
|
+
"react/forbid-dom-props": ["off", { forbid: [] }],
|
|
123
83
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
84
|
+
// Disallow certain elements
|
|
85
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
|
|
86
|
+
"react/forbid-elements": ["off", { forbid: [] }],
|
|
127
87
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
88
|
+
// Disallow using another component's `propTypes`
|
|
89
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
90
|
+
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }],
|
|
131
91
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
92
|
+
// Disallow certain `propTypes`
|
|
93
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
|
|
94
|
+
"react/forbid-prop-types": [
|
|
95
|
+
"error",
|
|
96
|
+
{
|
|
97
|
+
forbid: ["any", "array", "object"],
|
|
98
|
+
checkContextTypes: true,
|
|
99
|
+
checkChildContextTypes: true,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
135
102
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
103
|
+
// Enforce a specific `function` type for function components
|
|
104
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
|
|
105
|
+
"react/function-component-definition": [
|
|
106
|
+
"error",
|
|
107
|
+
{
|
|
108
|
+
namedComponents: ["function-declaration", "arrow-function", "function-expression"],
|
|
109
|
+
unnamedComponents: ["arrow-function", "function-expression"],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
145
112
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
113
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
114
|
+
"react/hook-use-state": "off",
|
|
149
115
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
116
|
+
// Enforce sandbox attribute on `iframe` elements
|
|
117
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/iframe-missing-sandbox.md
|
|
118
|
+
"react/iframe-missing-sandbox": "off",
|
|
153
119
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"error",
|
|
158
|
-
{
|
|
159
|
-
extensions: [".jsx"],
|
|
160
|
-
},
|
|
161
|
-
],
|
|
120
|
+
// Enforce boolean attributes notation in JSX
|
|
121
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
122
|
+
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
162
123
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// Enforce shorthand or standard form for React fragments
|
|
168
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
169
|
-
"react/jsx-fragments": ["error", "syntax"],
|
|
170
|
-
|
|
171
|
-
// Enforce event handler naming conventions in JSX
|
|
172
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
173
|
-
"react/jsx-handler-names": [
|
|
174
|
-
"off",
|
|
175
|
-
{
|
|
176
|
-
eventHandlerPrefix: "handle",
|
|
177
|
-
eventHandlerPropPrefix: "on",
|
|
178
|
-
},
|
|
179
|
-
],
|
|
124
|
+
// Enforce or disallow spaces inside of curly braces in JSX attributes and expressions
|
|
125
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
|
|
126
|
+
"react/jsx-child-element-spacing": "off",
|
|
180
127
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// Enforce props indentation in JSX
|
|
186
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
187
|
-
"react/jsx-indent-props": ["error", 2],
|
|
188
|
-
|
|
189
|
-
// Disallow missing key props in iterators/collection literals
|
|
190
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
|
|
191
|
-
"react/jsx-key": "error",
|
|
192
|
-
|
|
193
|
-
// Enforce JSX maximum depth
|
|
194
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md
|
|
195
|
-
"react/jsx-max-depth": "off",
|
|
196
|
-
|
|
197
|
-
// Enforce maximum of props on a single line in JSX
|
|
198
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
199
|
-
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
200
|
-
|
|
201
|
-
// Require or prevent a new line after jsx elements and expressions
|
|
202
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md
|
|
203
|
-
"react/jsx-newline": "off",
|
|
204
|
-
|
|
205
|
-
// Disallow `.bind()` or arrow functions in JSX props
|
|
206
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
207
|
-
"react/jsx-no-bind": [
|
|
208
|
-
"error",
|
|
209
|
-
{
|
|
210
|
-
ignoreRefs: true,
|
|
211
|
-
allowArrowFunctions: true,
|
|
212
|
-
allowFunctions: false,
|
|
213
|
-
allowBind: false,
|
|
214
|
-
ignoreDOMComponents: true,
|
|
215
|
-
},
|
|
216
|
-
],
|
|
128
|
+
// Enforce closing bracket location in JSX
|
|
129
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
|
|
130
|
+
"react/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
217
131
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
132
|
+
// Enforce closing tag location for multiline JSX
|
|
133
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
134
|
+
"react/jsx-closing-tag-location": "error",
|
|
221
135
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
136
|
+
// Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes
|
|
137
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
138
|
+
"react/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }],
|
|
225
139
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
140
|
+
// Enforce consistent linebreaks in curly braces in JSX attributes and expressions
|
|
141
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
142
|
+
"react/jsx-curly-newline": [
|
|
143
|
+
"error",
|
|
144
|
+
{
|
|
145
|
+
multiline: "consistent",
|
|
146
|
+
singleline: "consistent",
|
|
147
|
+
},
|
|
148
|
+
],
|
|
229
149
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
150
|
+
// Enforce or disallow spaces inside of curly braces in JSX attributes and expressions
|
|
151
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
|
|
152
|
+
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
233
153
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
154
|
+
// Enforce or disallow spaces around equal signs in JSX attributes
|
|
155
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
|
156
|
+
"react/jsx-equals-spacing": ["error", "never"],
|
|
237
157
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
[
|
|
158
|
+
// Disallow file extensions that may contain JSX
|
|
159
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
160
|
+
"react/jsx-filename-extension": [
|
|
161
|
+
"error",
|
|
243
162
|
{
|
|
244
|
-
|
|
245
|
-
props: ["to"],
|
|
163
|
+
extensions: [".jsx"],
|
|
246
164
|
},
|
|
247
165
|
],
|
|
248
|
-
],
|
|
249
166
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// Disallow undeclared variables in JSX
|
|
255
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
256
|
-
"react/jsx-no-undef": "error",
|
|
257
|
-
|
|
258
|
-
// Disallow unnecessary fragments
|
|
259
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
260
|
-
"react/jsx-no-useless-fragment": "error",
|
|
261
|
-
|
|
262
|
-
// Require one JSX element per line
|
|
263
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
264
|
-
"react/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
265
|
-
|
|
266
|
-
// Enforce PascalCase for user-defined JSX components
|
|
267
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
268
|
-
"react/jsx-pascal-case": [
|
|
269
|
-
"error",
|
|
270
|
-
{
|
|
271
|
-
allowAllCaps: true,
|
|
272
|
-
ignore: [],
|
|
273
|
-
},
|
|
274
|
-
],
|
|
167
|
+
// Enforce proper position of the first property in JSX
|
|
168
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
169
|
+
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
275
170
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// Disallow JSX prop spreading the same identifier multiple times
|
|
281
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
|
|
282
|
-
"react/jsx-props-no-spread-multi": "off",
|
|
283
|
-
|
|
284
|
-
// Disallow JSX prop spreading
|
|
285
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
|
|
286
|
-
"react/jsx-props-no-spreading": "off",
|
|
287
|
-
|
|
288
|
-
// Enforce defaultProps declarations alphabetical sorting
|
|
289
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
|
|
290
|
-
// This rule is deprecated. It was replaced by react/sort-default-props
|
|
291
|
-
"react/jsx-sort-default-props": [
|
|
292
|
-
"off",
|
|
293
|
-
{
|
|
294
|
-
ignoreCase: true,
|
|
295
|
-
},
|
|
296
|
-
],
|
|
171
|
+
// Enforce shorthand or standard form for React fragments
|
|
172
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
173
|
+
"react/jsx-fragments": ["error", "syntax"],
|
|
297
174
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
noSortAlphabetically: false,
|
|
308
|
-
reservedFirst: true,
|
|
309
|
-
},
|
|
310
|
-
],
|
|
175
|
+
// Enforce event handler naming conventions in JSX
|
|
176
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
177
|
+
"react/jsx-handler-names": [
|
|
178
|
+
"off",
|
|
179
|
+
{
|
|
180
|
+
eventHandlerPrefix: "handle",
|
|
181
|
+
eventHandlerPropPrefix: "on",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
311
184
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
"react/jsx-space-before-closing": ["off", "always"],
|
|
316
|
-
|
|
317
|
-
// Enforce whitespace in and around the JSX opening and closing brackets
|
|
318
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
|
|
319
|
-
"react/jsx-tag-spacing": [
|
|
320
|
-
"error",
|
|
321
|
-
{
|
|
322
|
-
closingSlash: "never",
|
|
323
|
-
beforeSelfClosing: "always",
|
|
324
|
-
afterOpening: "never",
|
|
325
|
-
beforeClosing: "never",
|
|
326
|
-
},
|
|
327
|
-
],
|
|
185
|
+
// Enforce JSX indentation
|
|
186
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
|
|
187
|
+
"react/jsx-indent": ["error", 2],
|
|
328
188
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
// Disallow variables used in JSX to be incorrectly marked as unused
|
|
334
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
335
|
-
"react/jsx-uses-vars": "error",
|
|
336
|
-
|
|
337
|
-
// Disallow missing parentheses around multiline JSX
|
|
338
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
|
339
|
-
"react/jsx-wrap-multilines": [
|
|
340
|
-
"error",
|
|
341
|
-
{
|
|
342
|
-
declaration: "parens-new-line",
|
|
343
|
-
assignment: "parens-new-line",
|
|
344
|
-
return: "parens-new-line",
|
|
345
|
-
arrow: "parens-new-line",
|
|
346
|
-
condition: "parens-new-line",
|
|
347
|
-
logical: "parens-new-line",
|
|
348
|
-
prop: "parens-new-line",
|
|
349
|
-
},
|
|
350
|
-
],
|
|
189
|
+
// Enforce props indentation in JSX
|
|
190
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
191
|
+
"react/jsx-indent-props": ["error", 2],
|
|
351
192
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
193
|
+
// Disallow missing key props in iterators/collection literals
|
|
194
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
|
|
195
|
+
"react/jsx-key": "error",
|
|
355
196
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
197
|
+
// Enforce JSX maximum depth
|
|
198
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md
|
|
199
|
+
"react/jsx-max-depth": "off",
|
|
359
200
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
201
|
+
// Enforce maximum of props on a single line in JSX
|
|
202
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
203
|
+
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
363
204
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
205
|
+
// Require or prevent a new line after jsx elements and expressions
|
|
206
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md
|
|
207
|
+
"react/jsx-newline": "off",
|
|
367
208
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
209
|
+
// Disallow `.bind()` or arrow functions in JSX props
|
|
210
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
211
|
+
"react/jsx-no-bind": [
|
|
212
|
+
"error",
|
|
213
|
+
{
|
|
214
|
+
ignoreRefs: true,
|
|
215
|
+
allowArrowFunctions: true,
|
|
216
|
+
allowFunctions: false,
|
|
217
|
+
allowBind: false,
|
|
218
|
+
ignoreDOMComponents: true,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
371
221
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
222
|
+
// Disallow comments from being inserted as text nodes
|
|
223
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
224
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
225
|
+
|
|
226
|
+
// Disallows JSX context provider values from taking values that will cause needless rerenders
|
|
227
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
|
|
228
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
229
|
+
|
|
230
|
+
// Disallow duplicate properties in JSX
|
|
231
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
|
|
232
|
+
"react/jsx-no-duplicate-props": ["error", { ignoreCase: true }],
|
|
233
|
+
|
|
234
|
+
// Disallow problematic leaked values from being rendered
|
|
235
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
236
|
+
"react/jsx-no-leaked-render": ["error", { validStrategies: ["ternary", "coerce"] }],
|
|
237
|
+
|
|
238
|
+
// Disallow usage of string literals in JSX
|
|
239
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
|
|
240
|
+
"react/jsx-no-literals": ["off", { noStrings: true }],
|
|
241
|
+
|
|
242
|
+
// Disallow usage of javascript: `URLs
|
|
243
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
|
|
244
|
+
"react/jsx-no-script-url": [
|
|
245
|
+
"error",
|
|
246
|
+
[
|
|
247
|
+
{
|
|
248
|
+
name: "Link",
|
|
249
|
+
props: ["to"],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
],
|
|
375
253
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
254
|
+
// Disallow `target="_blank"` attribute without `rel="noreferrer"
|
|
255
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
256
|
+
"react/jsx-no-target-blank": ["error", { enforceDynamicLinks: "always" }],
|
|
379
257
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
258
|
+
// Disallow undeclared variables in JSX
|
|
259
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
260
|
+
"react/jsx-no-undef": "error",
|
|
383
261
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
262
|
+
// Disallow unnecessary fragments
|
|
263
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
264
|
+
"react/jsx-no-useless-fragment": "error",
|
|
387
265
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
266
|
+
// Require one JSX element per line
|
|
267
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
268
|
+
"react/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
391
269
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
270
|
+
// Enforce PascalCase for user-defined JSX components
|
|
271
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
272
|
+
"react/jsx-pascal-case": [
|
|
273
|
+
"error",
|
|
274
|
+
{
|
|
275
|
+
allowAllCaps: true,
|
|
276
|
+
ignore: [],
|
|
277
|
+
},
|
|
278
|
+
],
|
|
395
279
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
280
|
+
// Disallow multiple spaces between inline JSX props
|
|
281
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
|
|
282
|
+
"react/jsx-props-no-multi-spaces": "error",
|
|
399
283
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
284
|
+
// Disallow JSX prop spreading the same identifier multiple times
|
|
285
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
|
|
286
|
+
"react/jsx-props-no-spread-multi": "off",
|
|
403
287
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
288
|
+
// Disallow JSX prop spreading
|
|
289
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
|
|
290
|
+
"react/jsx-props-no-spreading": "off",
|
|
407
291
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
"
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
292
|
+
// Enforce defaultProps declarations alphabetical sorting
|
|
293
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
|
|
294
|
+
// This rule is deprecated. It was replaced by react/sort-default-props
|
|
295
|
+
"react/jsx-sort-default-props": [
|
|
296
|
+
"off",
|
|
297
|
+
{
|
|
298
|
+
ignoreCase: true,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
416
301
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
431
|
-
"react/no-render-return-value": "error",
|
|
432
|
-
|
|
433
|
-
// Disallow usage of `setState`
|
|
434
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
|
|
435
|
-
"react/no-set-state": "off",
|
|
436
|
-
|
|
437
|
-
// Disallow using string references
|
|
438
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
439
|
-
"react/no-string-refs": "error",
|
|
440
|
-
|
|
441
|
-
// Disallow `this` from being used in stateless functional components
|
|
442
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
|
|
443
|
-
"react/no-this-in-sfc": "error",
|
|
444
|
-
|
|
445
|
-
// Disallow common typos
|
|
446
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-typos.md
|
|
447
|
-
"react/no-typos": "error",
|
|
448
|
-
|
|
449
|
-
// Disallow unescaped HTML entities from appearing in markup
|
|
450
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
451
|
-
"react/no-unescaped-entities": "off",
|
|
452
|
-
|
|
453
|
-
// Disallow usage of unknown DOM property
|
|
454
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
455
|
-
"react/no-unknown-property": "error",
|
|
456
|
-
|
|
457
|
-
// Disallow usage of unsafe lifecycle methods
|
|
458
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
|
|
459
|
-
"react/no-unsafe": "off",
|
|
460
|
-
|
|
461
|
-
// Disallow creating unstable components inside components
|
|
462
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
463
|
-
"react/no-unstable-nested-components": "error",
|
|
464
|
-
|
|
465
|
-
// Disallow declaring unused methods of component class
|
|
466
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md
|
|
467
|
-
"react/no-unused-class-component-methods": "error",
|
|
468
|
-
|
|
469
|
-
// Disallow definitions of unused `propTypes`
|
|
470
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
471
|
-
"react/no-unused-prop-types": [
|
|
472
|
-
"error",
|
|
473
|
-
{
|
|
474
|
-
customValidators: [],
|
|
475
|
-
skipShapeProps: true,
|
|
476
|
-
},
|
|
477
|
-
],
|
|
302
|
+
// Enforce props alphabetical sorting
|
|
303
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
304
|
+
"react/jsx-sort-props": [
|
|
305
|
+
"off",
|
|
306
|
+
{
|
|
307
|
+
ignoreCase: true,
|
|
308
|
+
callbacksLast: false,
|
|
309
|
+
shorthandFirst: false,
|
|
310
|
+
shorthandLast: false,
|
|
311
|
+
noSortAlphabetically: false,
|
|
312
|
+
reservedFirst: true,
|
|
313
|
+
},
|
|
314
|
+
],
|
|
478
315
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// Disallow usage of `setState` in `componentWillUpdate`
|
|
484
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
485
|
-
"react/no-will-update-set-state": "error",
|
|
486
|
-
|
|
487
|
-
// Enforce ES5 or ES6 class for React Components
|
|
488
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
489
|
-
"react/prefer-es6-class": ["error", "always"],
|
|
490
|
-
|
|
491
|
-
// Prefer exact `proptype` definitions
|
|
492
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md
|
|
493
|
-
"react/prefer-exact-props": "error",
|
|
494
|
-
|
|
495
|
-
// Enforce that props are read-only
|
|
496
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
|
|
497
|
-
"react/prefer-read-only-props": "off",
|
|
498
|
-
|
|
499
|
-
// Enforce stateless components to be written as a pure `function`
|
|
500
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
501
|
-
"react/prefer-stateless-function": ["error", { ignorePureComponents: true }],
|
|
502
|
-
|
|
503
|
-
// Disallow missing props validation in a React component definition
|
|
504
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md
|
|
505
|
-
"react/prop-types": [
|
|
506
|
-
"error",
|
|
507
|
-
{
|
|
508
|
-
ignore: [],
|
|
509
|
-
customValidators: [],
|
|
510
|
-
skipUndeclared: false,
|
|
511
|
-
},
|
|
512
|
-
],
|
|
316
|
+
// Enforce spacing before closing bracket in JSX
|
|
317
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
|
|
318
|
+
// This rule is deprecated. It was replaced by react/jsx-tag-spacing
|
|
319
|
+
"react/jsx-space-before-closing": ["off", "always"],
|
|
513
320
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
321
|
+
// Enforce whitespace in and around the JSX opening and closing brackets
|
|
322
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
|
|
323
|
+
"react/jsx-tag-spacing": [
|
|
324
|
+
"error",
|
|
325
|
+
{
|
|
326
|
+
closingSlash: "never",
|
|
327
|
+
beforeSelfClosing: "always",
|
|
328
|
+
afterOpening: "never",
|
|
329
|
+
beforeClosing: "never",
|
|
330
|
+
},
|
|
331
|
+
],
|
|
517
332
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
"error",
|
|
522
|
-
{
|
|
523
|
-
forbidDefaultForRequired: true,
|
|
524
|
-
},
|
|
525
|
-
],
|
|
333
|
+
// Disallow `React` to be incorrectly marked as unused
|
|
334
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
|
|
335
|
+
"react/jsx-uses-react": "off",
|
|
526
336
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
337
|
+
// Disallow variables used in JSX to be incorrectly marked as unused
|
|
338
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
339
|
+
"react/jsx-uses-vars": "error",
|
|
340
|
+
|
|
341
|
+
// Disallow missing parentheses around multiline JSX
|
|
342
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
|
343
|
+
"react/jsx-wrap-multilines": [
|
|
344
|
+
"error",
|
|
345
|
+
{
|
|
346
|
+
declaration: "parens-new-line",
|
|
347
|
+
assignment: "parens-new-line",
|
|
348
|
+
return: "parens-new-line",
|
|
349
|
+
arrow: "parens-new-line",
|
|
350
|
+
condition: "parens-new-line",
|
|
351
|
+
logical: "parens-new-line",
|
|
352
|
+
prop: "parens-new-line",
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
|
|
356
|
+
// Disallow when `this.state` is accessed within `setState`
|
|
357
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md
|
|
358
|
+
"react/no-access-state-in-setstate": "error",
|
|
359
|
+
|
|
360
|
+
// Disallow adjacent inline elements not separated by whitespace
|
|
361
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
|
|
362
|
+
"react/no-adjacent-inline-elements": "off",
|
|
363
|
+
|
|
364
|
+
// Disallow usage of `Array` index in keys
|
|
365
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
366
|
+
"react/no-array-index-key": "error",
|
|
367
|
+
|
|
368
|
+
// Lifecycle methods should be methods on the prototype, not class fields
|
|
369
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-arrow-function-lifecycle.md
|
|
370
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
371
|
+
|
|
372
|
+
// Disallow passing of children as props
|
|
373
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
|
|
374
|
+
"react/no-children-prop": "error",
|
|
375
|
+
|
|
376
|
+
// Disallow usage of dangerous JSX properties
|
|
377
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md
|
|
378
|
+
"react/no-danger": "warn",
|
|
379
|
+
|
|
380
|
+
// Disallow when a DOM element is using both `children` and `dangerouslySetInnerHTML`
|
|
381
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
|
|
382
|
+
"react/no-danger-with-children": "error",
|
|
383
|
+
|
|
384
|
+
// Disallow usage of deprecated methods
|
|
385
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
|
386
|
+
"react/no-deprecated": "error",
|
|
387
|
+
|
|
388
|
+
// Disallow usage of `setState` in `componentDidMount`
|
|
389
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
|
|
390
|
+
"react/no-did-mount-set-state": "off",
|
|
391
|
+
|
|
392
|
+
// Disallow usage of `setState` in `componentDidUpdate`
|
|
393
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
|
394
|
+
"react/no-did-update-set-state": "error",
|
|
395
|
+
|
|
396
|
+
// Disallow direct mutation of `this.state`
|
|
397
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
|
398
|
+
"react/no-direct-mutation-state": "error",
|
|
399
|
+
|
|
400
|
+
// Disallow usage of `findDOMNode`
|
|
401
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
|
402
|
+
"react/no-find-dom-node": "error",
|
|
403
|
+
|
|
404
|
+
// Disallow usage of invalid attributes
|
|
405
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-invalid-html-attribute.md
|
|
406
|
+
"react/no-invalid-html-attribute": "error",
|
|
407
|
+
|
|
408
|
+
// Disallow usage of `isMounted`
|
|
409
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
|
|
410
|
+
"react/no-is-mounted": "error",
|
|
411
|
+
|
|
412
|
+
// Disallow multiple component definition per file
|
|
413
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
|
|
414
|
+
"react/no-multi-comp": [
|
|
415
|
+
"error",
|
|
416
|
+
{
|
|
417
|
+
ignoreStateless: false,
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
|
|
421
|
+
// Enforce that namespaces are not used in React elements
|
|
422
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-namespace.md
|
|
423
|
+
"react/no-namespace": "error",
|
|
424
|
+
|
|
425
|
+
// Disallow usage of referential-type variables as default param in functional component
|
|
426
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-object-type-as-default-prop.md
|
|
427
|
+
"react/no-object-type-as-default-prop": "off",
|
|
428
|
+
|
|
429
|
+
// Disallow usage of `shouldComponentUpdate` when extending `React.PureComponent`
|
|
430
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md
|
|
431
|
+
"react/no-redundant-should-component-update": "error",
|
|
432
|
+
|
|
433
|
+
// Disallow usage of the return value of `ReactDOM.render`
|
|
434
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
435
|
+
"react/no-render-return-value": "error",
|
|
436
|
+
|
|
437
|
+
// Disallow usage of `setState`
|
|
438
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
|
|
439
|
+
"react/no-set-state": "off",
|
|
440
|
+
|
|
441
|
+
// Disallow using string references
|
|
442
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
443
|
+
"react/no-string-refs": "error",
|
|
444
|
+
|
|
445
|
+
// Disallow `this` from being used in stateless functional components
|
|
446
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
|
|
447
|
+
"react/no-this-in-sfc": "error",
|
|
448
|
+
|
|
449
|
+
// Disallow common typos
|
|
450
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-typos.md
|
|
451
|
+
"react/no-typos": "error",
|
|
452
|
+
|
|
453
|
+
// Disallow unescaped HTML entities from appearing in markup
|
|
454
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
455
|
+
"react/no-unescaped-entities": "off",
|
|
456
|
+
|
|
457
|
+
// Disallow usage of unknown DOM property
|
|
458
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
459
|
+
"react/no-unknown-property": "error",
|
|
460
|
+
|
|
461
|
+
// Disallow usage of unsafe lifecycle methods
|
|
462
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
|
|
463
|
+
"react/no-unsafe": "off",
|
|
464
|
+
|
|
465
|
+
// Disallow creating unstable components inside components
|
|
466
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
467
|
+
"react/no-unstable-nested-components": "error",
|
|
468
|
+
|
|
469
|
+
// Disallow declaring unused methods of component class
|
|
470
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md
|
|
471
|
+
"react/no-unused-class-component-methods": "error",
|
|
472
|
+
|
|
473
|
+
// Disallow definitions of unused `propTypes`
|
|
474
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
475
|
+
"react/no-unused-prop-types": [
|
|
476
|
+
"error",
|
|
477
|
+
{
|
|
478
|
+
customValidators: [],
|
|
479
|
+
skipShapeProps: true,
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
|
|
483
|
+
// Disallow definitions of unused state
|
|
484
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
|
|
485
|
+
"react/no-unused-state": "error",
|
|
486
|
+
|
|
487
|
+
// Disallow usage of `setState` in `componentWillUpdate`
|
|
488
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
489
|
+
"react/no-will-update-set-state": "error",
|
|
490
|
+
|
|
491
|
+
// Enforce ES5 or ES6 class for React Components
|
|
492
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
493
|
+
"react/prefer-es6-class": ["error", "always"],
|
|
494
|
+
|
|
495
|
+
// Prefer exact `proptype` definitions
|
|
496
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md
|
|
497
|
+
"react/prefer-exact-props": "error",
|
|
498
|
+
|
|
499
|
+
// Enforce that props are read-only
|
|
500
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
|
|
501
|
+
"react/prefer-read-only-props": "off",
|
|
502
|
+
|
|
503
|
+
// Enforce stateless components to be written as a pure `function`
|
|
504
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
505
|
+
"react/prefer-stateless-function": ["error", { ignorePureComponents: true }],
|
|
506
|
+
|
|
507
|
+
// Disallow missing props validation in a React component definition
|
|
508
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md
|
|
509
|
+
"react/prop-types": [
|
|
510
|
+
"error",
|
|
511
|
+
{
|
|
512
|
+
ignore: [],
|
|
513
|
+
customValidators: [],
|
|
514
|
+
skipUndeclared: false,
|
|
515
|
+
},
|
|
516
|
+
],
|
|
517
|
+
|
|
518
|
+
// Disallow missing `React` when using JSX
|
|
519
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
|
|
520
|
+
"react/react-in-jsx-scope": "off",
|
|
521
|
+
|
|
522
|
+
// Enforce a `defaultProps` definition for every prop that is not a required prop
|
|
523
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
524
|
+
"react/require-default-props": [
|
|
525
|
+
"error",
|
|
526
|
+
{
|
|
527
|
+
forbidDefaultForRequired: true,
|
|
528
|
+
},
|
|
529
|
+
],
|
|
530
|
+
|
|
531
|
+
// Enforce React components to have a `shouldComponentUpdate` method
|
|
532
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
|
|
533
|
+
"react/require-optimization": ["off", { allowDecorators: [] }],
|
|
534
|
+
|
|
535
|
+
// Enforce ES5 or ES6 class for returning value in `render` function
|
|
536
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
|
537
|
+
"react/require-render-return": "error",
|
|
538
|
+
|
|
539
|
+
// Disallow extra closing tags for components without children
|
|
540
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
541
|
+
"react/self-closing-comp": "error",
|
|
542
|
+
|
|
543
|
+
// Enforce component methods order
|
|
544
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
|
|
545
|
+
"react/sort-comp": [
|
|
546
|
+
"error",
|
|
547
|
+
{
|
|
548
|
+
order: [
|
|
549
|
+
"static-variables",
|
|
550
|
+
"static-methods",
|
|
551
|
+
"instance-variables",
|
|
552
|
+
"lifecycle",
|
|
553
|
+
"/^handle.+$/",
|
|
554
|
+
"/^on.+$/",
|
|
555
|
+
"getters",
|
|
556
|
+
"setters",
|
|
557
|
+
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
|
|
558
|
+
"instance-methods",
|
|
559
|
+
"everything-else",
|
|
560
|
+
"rendering",
|
|
585
561
|
],
|
|
586
|
-
|
|
562
|
+
groups: {
|
|
563
|
+
lifecycle: [
|
|
564
|
+
"displayName",
|
|
565
|
+
"propTypes",
|
|
566
|
+
"contextTypes",
|
|
567
|
+
"childContextTypes",
|
|
568
|
+
"mixins",
|
|
569
|
+
"statics",
|
|
570
|
+
"defaultProps",
|
|
571
|
+
"constructor",
|
|
572
|
+
"getDefaultProps",
|
|
573
|
+
"getInitialState",
|
|
574
|
+
"state",
|
|
575
|
+
"getChildContext",
|
|
576
|
+
"getDerivedStateFromProps",
|
|
577
|
+
"componentWillMount",
|
|
578
|
+
"UNSAFE_componentWillMount",
|
|
579
|
+
"componentDidMount",
|
|
580
|
+
"componentWillReceiveProps",
|
|
581
|
+
"UNSAFE_componentWillReceiveProps",
|
|
582
|
+
"shouldComponentUpdate",
|
|
583
|
+
"componentWillUpdate",
|
|
584
|
+
"UNSAFE_componentWillUpdate",
|
|
585
|
+
"getSnapshotBeforeUpdate",
|
|
586
|
+
"componentDidUpdate",
|
|
587
|
+
"componentDidCatch",
|
|
588
|
+
"componentWillUnmount",
|
|
589
|
+
],
|
|
590
|
+
rendering: ["/^render.+$/", "render"],
|
|
591
|
+
},
|
|
587
592
|
},
|
|
588
|
-
|
|
589
|
-
],
|
|
593
|
+
],
|
|
590
594
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
// Enforce propTypes declarations alphabetical sorting
|
|
596
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
|
|
597
|
-
"react/sort-prop-types": [
|
|
598
|
-
"off",
|
|
599
|
-
{
|
|
600
|
-
ignoreCase: true,
|
|
601
|
-
callbacksLast: false,
|
|
602
|
-
requiredFirst: false,
|
|
603
|
-
sortShapeProp: true,
|
|
604
|
-
},
|
|
605
|
-
],
|
|
595
|
+
// Enforce defaultProps declarations alphabetical sorting
|
|
596
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-default-props.md
|
|
597
|
+
"react/sort-default-props": "off",
|
|
606
598
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
599
|
+
// Enforce propTypes declarations alphabetical sorting
|
|
600
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
|
|
601
|
+
"react/sort-prop-types": [
|
|
602
|
+
"off",
|
|
603
|
+
{
|
|
604
|
+
ignoreCase: true,
|
|
605
|
+
callbacksLast: false,
|
|
606
|
+
requiredFirst: false,
|
|
607
|
+
sortShapeProp: true,
|
|
608
|
+
},
|
|
609
|
+
],
|
|
610
610
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
611
|
+
// Enforce class component state initialization style
|
|
612
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
|
|
613
|
+
"react/state-in-constructor": ["error", "always"],
|
|
614
614
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
615
|
+
// Enforces where React component static properties should be positioned
|
|
616
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
|
|
617
|
+
"react/static-property-placement": ["error", "property assignment"],
|
|
618
618
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
619
|
+
// Enforce `style` prop value is an object
|
|
620
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
|
|
621
|
+
"react/style-prop-object": "error",
|
|
622
622
|
|
|
623
|
-
|
|
623
|
+
// Disallow void DOM elements (e.g. `<img />`, `<br />`) from receiving children
|
|
624
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
|
|
625
|
+
"react/void-dom-elements-no-children": "error",
|
|
624
626
|
|
|
625
|
-
|
|
626
|
-
// https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
627
|
-
// https://react.dev/reference/rules/rules-of-hooks
|
|
628
|
-
"react-hooks/rules-of-hooks": "error",
|
|
627
|
+
// eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hook
|
|
629
628
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
629
|
+
// Enforce Rules of Hooks
|
|
630
|
+
// https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
631
|
+
// https://react.dev/reference/rules/rules-of-hooks
|
|
632
|
+
"react-hooks/rules-of-hooks": "error",
|
|
633
|
+
|
|
634
|
+
// Verify the list of the dependencies for Hooks like `useEffect` and similar
|
|
635
|
+
// https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
636
|
+
// https://github.com/facebook/react/issues/14920
|
|
637
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
638
|
+
},
|
|
639
|
+
"import-x",
|
|
640
|
+
importNs,
|
|
641
|
+
),
|
|
635
642
|
settings: {
|
|
636
643
|
react: {
|
|
637
644
|
pragma: "React",
|
|
638
645
|
version: "detect",
|
|
639
646
|
},
|
|
640
|
-
"import/resolver": {
|
|
647
|
+
"import-x/resolver": {
|
|
641
648
|
node: {
|
|
642
649
|
extensions: [".js", ".jsx"],
|
|
643
650
|
},
|
|
@@ -648,11 +655,11 @@ export const reactRules = {
|
|
|
648
655
|
"Object.freeze", // https://tc39.github.io/ecma262/#sec-object.freeze
|
|
649
656
|
],
|
|
650
657
|
},
|
|
651
|
-
};
|
|
658
|
+
});
|
|
652
659
|
|
|
653
|
-
export const reactTypescriptRules = {
|
|
660
|
+
export const reactTypescriptRules = ({ files, import: importNs = "import-x" } = {}) => ({
|
|
654
661
|
settings: {
|
|
655
|
-
"import/resolver": {
|
|
662
|
+
"import-x/resolver": {
|
|
656
663
|
node: {
|
|
657
664
|
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
658
665
|
},
|
|
@@ -663,40 +670,45 @@ export const reactTypescriptRules = {
|
|
|
663
670
|
jsxPragma: null,
|
|
664
671
|
},
|
|
665
672
|
},
|
|
666
|
-
rules:
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
"
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
673
|
+
rules: prefix(
|
|
674
|
+
{
|
|
675
|
+
// eslint-plugin-import-x https://github.com/un-ts/eslint-plugin-import-x
|
|
676
|
+
|
|
677
|
+
// import-x/extensions
|
|
678
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
|
|
679
|
+
"import-x/extensions": [
|
|
680
|
+
"error",
|
|
681
|
+
"ignorePackages",
|
|
682
|
+
{
|
|
683
|
+
js: "never",
|
|
684
|
+
jsx: "never",
|
|
685
|
+
ts: "never",
|
|
686
|
+
tsx: "never",
|
|
687
|
+
},
|
|
688
|
+
],
|
|
681
689
|
|
|
682
|
-
|
|
690
|
+
// eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
|
|
683
691
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
692
|
+
// Enforce a defaultProps definition for every prop that is not a required prop
|
|
693
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
694
|
+
"react/require-default-props": "off",
|
|
687
695
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
696
|
+
// Disallow file extensions that may contain JSX
|
|
697
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
698
|
+
"react/jsx-filename-extension": [
|
|
699
|
+
"error",
|
|
700
|
+
{
|
|
701
|
+
extensions: [".jsx", ".tsx"],
|
|
702
|
+
},
|
|
703
|
+
],
|
|
704
|
+
},
|
|
705
|
+
"import-x",
|
|
706
|
+
importNs,
|
|
707
|
+
),
|
|
708
|
+
files,
|
|
709
|
+
});
|
|
698
710
|
|
|
699
|
-
export const reactTestRules = {
|
|
711
|
+
export const reactTestRules = ({ files } = {}) => ({
|
|
700
712
|
plugins: {
|
|
701
713
|
"testing-library": testingLibraryPlugin,
|
|
702
714
|
"jest-dom": jestDom,
|
|
@@ -858,4 +870,5 @@ export const reactTestRules = {
|
|
|
858
870
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
|
|
859
871
|
"testing-library/render-result-naming-convention": "error",
|
|
860
872
|
},
|
|
861
|
-
|
|
873
|
+
files,
|
|
874
|
+
});
|