@pplancq/eslint-config 6.0.16 → 6.0.18
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 +20 -0
- package/README.md +1 -1
- package/bin/init.mjs +4 -4
- package/main.js +18 -18
- package/package.json +11 -11
- package/rules/base.js +509 -509
- package/rules/import.js +87 -87
- package/rules/playwright.js +55 -55
- package/rules/prettier.js +107 -107
- package/rules/react-jsx-a11y.js +70 -70
- package/rules/react.js +256 -256
- package/rules/typescript.js +157 -157
- package/rules/vitest.js +56 -56
package/rules/react.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import jestDom from "eslint-plugin-jest-dom";
|
|
2
|
+
import reactPlugin from "eslint-plugin-react";
|
|
3
|
+
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
4
|
+
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
5
5
|
|
|
6
6
|
export const reactRules = {
|
|
7
7
|
plugins: {
|
|
8
8
|
react: reactPlugin,
|
|
9
|
-
|
|
9
|
+
"react-hooks": reactHooksPlugin,
|
|
10
10
|
},
|
|
11
11
|
languageOptions: {
|
|
12
12
|
parserOptions: {
|
|
@@ -20,12 +20,12 @@ export const reactRules = {
|
|
|
20
20
|
|
|
21
21
|
// import/extensions
|
|
22
22
|
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
"import/extensions": [
|
|
24
|
+
"error",
|
|
25
|
+
"ignorePackages",
|
|
26
26
|
{
|
|
27
|
-
js:
|
|
28
|
-
jsx:
|
|
27
|
+
js: "never",
|
|
28
|
+
jsx: "never",
|
|
29
29
|
},
|
|
30
30
|
],
|
|
31
31
|
|
|
@@ -33,19 +33,19 @@ export const reactRules = {
|
|
|
33
33
|
|
|
34
34
|
// Enforces consistent naming for boolean props
|
|
35
35
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
"react/boolean-prop-naming": [
|
|
37
|
+
"off",
|
|
38
38
|
{
|
|
39
|
-
propTypeNames: [
|
|
40
|
-
rule:
|
|
41
|
-
message:
|
|
39
|
+
propTypeNames: ["bool", "mutuallyExclusiveTrueProps"],
|
|
40
|
+
rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+",
|
|
41
|
+
message: "",
|
|
42
42
|
},
|
|
43
43
|
],
|
|
44
44
|
|
|
45
45
|
// Disallow usage of `button` elements without an explicit `type` attribute
|
|
46
46
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
"react/button-has-type": [
|
|
48
|
+
"error",
|
|
49
49
|
{
|
|
50
50
|
button: true,
|
|
51
51
|
submit: true,
|
|
@@ -55,42 +55,42 @@ export const reactRules = {
|
|
|
55
55
|
|
|
56
56
|
// Enforce using `onChange` or `readonly` attribute when `checked` is used
|
|
57
57
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md
|
|
58
|
-
|
|
58
|
+
"react/checked-requires-onchange-or-readonly": "off",
|
|
59
59
|
|
|
60
60
|
// Enforce all `defaultProps` have a corresponding non-required `PropType`
|
|
61
61
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
|
|
62
|
-
|
|
62
|
+
"react/default-props-match-prop-types": ["error", { allowRequiredDefaults: false }],
|
|
63
63
|
|
|
64
64
|
// Enforce consistent usage of destructuring assignment of props, state, and context
|
|
65
65
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
|
|
66
|
-
|
|
66
|
+
"react/destructuring-assignment": ["error", "always"],
|
|
67
67
|
|
|
68
68
|
// Disallow missing `displayName` in a React component definition
|
|
69
69
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
|
|
70
|
-
|
|
70
|
+
"react/display-name": "error",
|
|
71
71
|
|
|
72
72
|
// Disallow certain props on components
|
|
73
73
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
|
|
74
|
-
|
|
74
|
+
"react/forbid-component-props": ["off", { forbid: [] }],
|
|
75
75
|
|
|
76
76
|
// Disallow certain props on DOM Nodes
|
|
77
77
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md
|
|
78
|
-
|
|
78
|
+
"react/forbid-dom-props": ["off", { forbid: [] }],
|
|
79
79
|
|
|
80
80
|
// Disallow certain elements
|
|
81
81
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
|
|
82
|
-
|
|
82
|
+
"react/forbid-elements": ["off", { forbid: [] }],
|
|
83
83
|
|
|
84
84
|
// Disallow using another component's `propTypes`
|
|
85
85
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
86
|
-
|
|
86
|
+
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }],
|
|
87
87
|
|
|
88
88
|
// Disallow certain `propTypes`
|
|
89
89
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
"react/forbid-prop-types": [
|
|
91
|
+
"error",
|
|
92
92
|
{
|
|
93
|
-
forbid: [
|
|
93
|
+
forbid: ["any", "array", "object"],
|
|
94
94
|
checkContextTypes: true,
|
|
95
95
|
checkChildContextTypes: true,
|
|
96
96
|
},
|
|
@@ -98,114 +98,114 @@ export const reactRules = {
|
|
|
98
98
|
|
|
99
99
|
// Enforce a specific `function` type for function components
|
|
100
100
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
"react/function-component-definition": [
|
|
102
|
+
"error",
|
|
103
103
|
{
|
|
104
|
-
namedComponents: [
|
|
105
|
-
unnamedComponents: [
|
|
104
|
+
namedComponents: ["function-declaration", "arrow-function", "function-expression"],
|
|
105
|
+
unnamedComponents: ["arrow-function", "function-expression"],
|
|
106
106
|
},
|
|
107
107
|
],
|
|
108
108
|
|
|
109
109
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
110
|
-
|
|
110
|
+
"react/hook-use-state": "off",
|
|
111
111
|
|
|
112
112
|
// Enforce sandbox attribute on `iframe` elements
|
|
113
113
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/iframe-missing-sandbox.md
|
|
114
|
-
|
|
114
|
+
"react/iframe-missing-sandbox": "off",
|
|
115
115
|
|
|
116
116
|
// Enforce boolean attributes notation in JSX
|
|
117
117
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
118
|
-
|
|
118
|
+
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
119
119
|
|
|
120
120
|
// Enforce or disallow spaces inside of curly braces in JSX attributes and expressions
|
|
121
121
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
|
|
122
|
-
|
|
122
|
+
"react/jsx-child-element-spacing": "off",
|
|
123
123
|
|
|
124
124
|
// Enforce closing bracket location in JSX
|
|
125
125
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
|
|
126
|
-
|
|
126
|
+
"react/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
127
127
|
|
|
128
128
|
// Enforce closing tag location for multiline JSX
|
|
129
129
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
130
|
-
|
|
130
|
+
"react/jsx-closing-tag-location": "error",
|
|
131
131
|
|
|
132
132
|
// Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes
|
|
133
133
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
134
|
-
|
|
134
|
+
"react/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }],
|
|
135
135
|
|
|
136
136
|
// Enforce consistent linebreaks in curly braces in JSX attributes and expressions
|
|
137
137
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
"react/jsx-curly-newline": [
|
|
139
|
+
"error",
|
|
140
140
|
{
|
|
141
|
-
multiline:
|
|
142
|
-
singleline:
|
|
141
|
+
multiline: "consistent",
|
|
142
|
+
singleline: "consistent",
|
|
143
143
|
},
|
|
144
144
|
],
|
|
145
145
|
|
|
146
146
|
// Enforce or disallow spaces inside of curly braces in JSX attributes and expressions
|
|
147
147
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
|
|
148
|
-
|
|
148
|
+
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
149
149
|
|
|
150
150
|
// Enforce or disallow spaces around equal signs in JSX attributes
|
|
151
151
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
|
152
|
-
|
|
152
|
+
"react/jsx-equals-spacing": ["error", "never"],
|
|
153
153
|
|
|
154
154
|
// Disallow file extensions that may contain JSX
|
|
155
155
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
"react/jsx-filename-extension": [
|
|
157
|
+
"error",
|
|
158
158
|
{
|
|
159
|
-
extensions: [
|
|
159
|
+
extensions: [".jsx"],
|
|
160
160
|
},
|
|
161
161
|
],
|
|
162
162
|
|
|
163
163
|
// Enforce proper position of the first property in JSX
|
|
164
164
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
165
|
-
|
|
165
|
+
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
166
166
|
|
|
167
167
|
// Enforce shorthand or standard form for React fragments
|
|
168
168
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
169
|
-
|
|
169
|
+
"react/jsx-fragments": ["error", "syntax"],
|
|
170
170
|
|
|
171
171
|
// Enforce event handler naming conventions in JSX
|
|
172
172
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
"react/jsx-handler-names": [
|
|
174
|
+
"off",
|
|
175
175
|
{
|
|
176
|
-
eventHandlerPrefix:
|
|
177
|
-
eventHandlerPropPrefix:
|
|
176
|
+
eventHandlerPrefix: "handle",
|
|
177
|
+
eventHandlerPropPrefix: "on",
|
|
178
178
|
},
|
|
179
179
|
],
|
|
180
180
|
|
|
181
181
|
// Enforce JSX indentation
|
|
182
182
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
|
|
183
|
-
|
|
183
|
+
"react/jsx-indent": ["error", 2],
|
|
184
184
|
|
|
185
185
|
// Enforce props indentation in JSX
|
|
186
186
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
187
|
-
|
|
187
|
+
"react/jsx-indent-props": ["error", 2],
|
|
188
188
|
|
|
189
189
|
// Disallow missing key props in iterators/collection literals
|
|
190
190
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
|
|
191
|
-
|
|
191
|
+
"react/jsx-key": "error",
|
|
192
192
|
|
|
193
193
|
// Enforce JSX maximum depth
|
|
194
194
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md
|
|
195
|
-
|
|
195
|
+
"react/jsx-max-depth": "off",
|
|
196
196
|
|
|
197
197
|
// Enforce maximum of props on a single line in JSX
|
|
198
198
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
199
|
-
|
|
199
|
+
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
200
200
|
|
|
201
201
|
// Require or prevent a new line after jsx elements and expressions
|
|
202
202
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md
|
|
203
|
-
|
|
203
|
+
"react/jsx-newline": "off",
|
|
204
204
|
|
|
205
205
|
// Disallow `.bind()` or arrow functions in JSX props
|
|
206
206
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
"react/jsx-no-bind": [
|
|
208
|
+
"error",
|
|
209
209
|
{
|
|
210
210
|
ignoreRefs: true,
|
|
211
211
|
allowArrowFunctions: true,
|
|
@@ -217,56 +217,56 @@ export const reactRules = {
|
|
|
217
217
|
|
|
218
218
|
// Disallow comments from being inserted as text nodes
|
|
219
219
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
220
|
-
|
|
220
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
221
221
|
|
|
222
222
|
// Disallows JSX context provider values from taking values that will cause needless rerenders
|
|
223
223
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
|
|
224
|
-
|
|
224
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
225
225
|
|
|
226
226
|
// Disallow duplicate properties in JSX
|
|
227
227
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
|
|
228
|
-
|
|
228
|
+
"react/jsx-no-duplicate-props": ["error", { ignoreCase: true }],
|
|
229
229
|
|
|
230
230
|
// Disallow problematic leaked values from being rendered
|
|
231
231
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
232
|
-
|
|
232
|
+
"react/jsx-no-leaked-render": ["error", { validStrategies: ["ternary", "coerce"] }],
|
|
233
233
|
|
|
234
234
|
// Disallow usage of string literals in JSX
|
|
235
235
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
|
|
236
|
-
|
|
236
|
+
"react/jsx-no-literals": ["off", { noStrings: true }],
|
|
237
237
|
|
|
238
238
|
// Disallow usage of javascript: `URLs
|
|
239
239
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
"react/jsx-no-script-url": [
|
|
241
|
+
"error",
|
|
242
242
|
[
|
|
243
243
|
{
|
|
244
|
-
name:
|
|
245
|
-
props: [
|
|
244
|
+
name: "Link",
|
|
245
|
+
props: ["to"],
|
|
246
246
|
},
|
|
247
247
|
],
|
|
248
248
|
],
|
|
249
249
|
|
|
250
250
|
// Disallow `target="_blank"` attribute without `rel="noreferrer"
|
|
251
251
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
252
|
-
|
|
252
|
+
"react/jsx-no-target-blank": ["error", { enforceDynamicLinks: "always" }],
|
|
253
253
|
|
|
254
254
|
// Disallow undeclared variables in JSX
|
|
255
255
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
256
|
-
|
|
256
|
+
"react/jsx-no-undef": "error",
|
|
257
257
|
|
|
258
258
|
// Disallow unnecessary fragments
|
|
259
259
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
260
|
-
|
|
260
|
+
"react/jsx-no-useless-fragment": "error",
|
|
261
261
|
|
|
262
262
|
// Require one JSX element per line
|
|
263
263
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
264
|
-
|
|
264
|
+
"react/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
265
265
|
|
|
266
266
|
// Enforce PascalCase for user-defined JSX components
|
|
267
267
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
"react/jsx-pascal-case": [
|
|
269
|
+
"error",
|
|
270
270
|
{
|
|
271
271
|
allowAllCaps: true,
|
|
272
272
|
ignore: [],
|
|
@@ -275,21 +275,21 @@ export const reactRules = {
|
|
|
275
275
|
|
|
276
276
|
// Disallow multiple spaces between inline JSX props
|
|
277
277
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
|
|
278
|
-
|
|
278
|
+
"react/jsx-props-no-multi-spaces": "error",
|
|
279
279
|
|
|
280
280
|
// Disallow JSX prop spreading the same identifier multiple times
|
|
281
281
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
|
|
282
|
-
|
|
282
|
+
"react/jsx-props-no-spread-multi": "off",
|
|
283
283
|
|
|
284
284
|
// Disallow JSX prop spreading
|
|
285
285
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
|
|
286
|
-
|
|
286
|
+
"react/jsx-props-no-spreading": "off",
|
|
287
287
|
|
|
288
288
|
// Enforce defaultProps declarations alphabetical sorting
|
|
289
289
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
|
|
290
290
|
// This rule is deprecated. It was replaced by react/sort-default-props
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
"react/jsx-sort-default-props": [
|
|
292
|
+
"off",
|
|
293
293
|
{
|
|
294
294
|
ignoreCase: true,
|
|
295
295
|
},
|
|
@@ -297,8 +297,8 @@ export const reactRules = {
|
|
|
297
297
|
|
|
298
298
|
// Enforce props alphabetical sorting
|
|
299
299
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
"react/jsx-sort-props": [
|
|
301
|
+
"off",
|
|
302
302
|
{
|
|
303
303
|
ignoreCase: true,
|
|
304
304
|
callbacksLast: false,
|
|
@@ -312,103 +312,103 @@ export const reactRules = {
|
|
|
312
312
|
// Enforce spacing before closing bracket in JSX
|
|
313
313
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
|
|
314
314
|
// This rule is deprecated. It was replaced by react/jsx-tag-spacing
|
|
315
|
-
|
|
315
|
+
"react/jsx-space-before-closing": ["off", "always"],
|
|
316
316
|
|
|
317
317
|
// Enforce whitespace in and around the JSX opening and closing brackets
|
|
318
318
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
"react/jsx-tag-spacing": [
|
|
320
|
+
"error",
|
|
321
321
|
{
|
|
322
|
-
closingSlash:
|
|
323
|
-
beforeSelfClosing:
|
|
324
|
-
afterOpening:
|
|
325
|
-
beforeClosing:
|
|
322
|
+
closingSlash: "never",
|
|
323
|
+
beforeSelfClosing: "always",
|
|
324
|
+
afterOpening: "never",
|
|
325
|
+
beforeClosing: "never",
|
|
326
326
|
},
|
|
327
327
|
],
|
|
328
328
|
|
|
329
329
|
// Disallow `React` to be incorrectly marked as unused
|
|
330
330
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
|
|
331
|
-
|
|
331
|
+
"react/jsx-uses-react": "off",
|
|
332
332
|
|
|
333
333
|
// Disallow variables used in JSX to be incorrectly marked as unused
|
|
334
334
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
335
|
-
|
|
335
|
+
"react/jsx-uses-vars": "error",
|
|
336
336
|
|
|
337
337
|
// Disallow missing parentheses around multiline JSX
|
|
338
338
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
"react/jsx-wrap-multilines": [
|
|
340
|
+
"error",
|
|
341
341
|
{
|
|
342
|
-
declaration:
|
|
343
|
-
assignment:
|
|
344
|
-
return:
|
|
345
|
-
arrow:
|
|
346
|
-
condition:
|
|
347
|
-
logical:
|
|
348
|
-
prop:
|
|
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
349
|
},
|
|
350
350
|
],
|
|
351
351
|
|
|
352
352
|
// Disallow when `this.state` is accessed within `setState`
|
|
353
353
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md
|
|
354
|
-
|
|
354
|
+
"react/no-access-state-in-setstate": "error",
|
|
355
355
|
|
|
356
356
|
// Disallow adjacent inline elements not separated by whitespace
|
|
357
357
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
|
|
358
|
-
|
|
358
|
+
"react/no-adjacent-inline-elements": "off",
|
|
359
359
|
|
|
360
360
|
// Disallow usage of `Array` index in keys
|
|
361
361
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
362
|
-
|
|
362
|
+
"react/no-array-index-key": "error",
|
|
363
363
|
|
|
364
364
|
// Lifecycle methods should be methods on the prototype, not class fields
|
|
365
365
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-arrow-function-lifecycle.md
|
|
366
|
-
|
|
366
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
367
367
|
|
|
368
368
|
// Disallow passing of children as props
|
|
369
369
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
|
|
370
|
-
|
|
370
|
+
"react/no-children-prop": "error",
|
|
371
371
|
|
|
372
372
|
// Disallow usage of dangerous JSX properties
|
|
373
373
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md
|
|
374
|
-
|
|
374
|
+
"react/no-danger": "warn",
|
|
375
375
|
|
|
376
376
|
// Disallow when a DOM element is using both `children` and `dangerouslySetInnerHTML`
|
|
377
377
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
|
|
378
|
-
|
|
378
|
+
"react/no-danger-with-children": "error",
|
|
379
379
|
|
|
380
380
|
// Disallow usage of deprecated methods
|
|
381
381
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
|
382
|
-
|
|
382
|
+
"react/no-deprecated": "error",
|
|
383
383
|
|
|
384
384
|
// Disallow usage of `setState` in `componentDidMount`
|
|
385
385
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
|
|
386
|
-
|
|
386
|
+
"react/no-did-mount-set-state": "off",
|
|
387
387
|
|
|
388
388
|
// Disallow usage of `setState` in `componentDidUpdate`
|
|
389
389
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
|
390
|
-
|
|
390
|
+
"react/no-did-update-set-state": "error",
|
|
391
391
|
|
|
392
392
|
// Disallow direct mutation of `this.state`
|
|
393
393
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
|
394
|
-
|
|
394
|
+
"react/no-direct-mutation-state": "error",
|
|
395
395
|
|
|
396
396
|
// Disallow usage of `findDOMNode`
|
|
397
397
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
|
398
|
-
|
|
398
|
+
"react/no-find-dom-node": "error",
|
|
399
399
|
|
|
400
400
|
// Disallow usage of invalid attributes
|
|
401
401
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-invalid-html-attribute.md
|
|
402
|
-
|
|
402
|
+
"react/no-invalid-html-attribute": "error",
|
|
403
403
|
|
|
404
404
|
// Disallow usage of `isMounted`
|
|
405
405
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
|
|
406
|
-
|
|
406
|
+
"react/no-is-mounted": "error",
|
|
407
407
|
|
|
408
408
|
// Disallow multiple component definition per file
|
|
409
409
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
|
|
410
|
-
|
|
411
|
-
|
|
410
|
+
"react/no-multi-comp": [
|
|
411
|
+
"error",
|
|
412
412
|
{
|
|
413
413
|
ignoreStateless: false,
|
|
414
414
|
},
|
|
@@ -416,60 +416,60 @@ export const reactRules = {
|
|
|
416
416
|
|
|
417
417
|
// Enforce that namespaces are not used in React elements
|
|
418
418
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-namespace.md
|
|
419
|
-
|
|
419
|
+
"react/no-namespace": "error",
|
|
420
420
|
|
|
421
421
|
// Disallow usage of referential-type variables as default param in functional component
|
|
422
422
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-object-type-as-default-prop.md
|
|
423
|
-
|
|
423
|
+
"react/no-object-type-as-default-prop": "off",
|
|
424
424
|
|
|
425
425
|
// Disallow usage of `shouldComponentUpdate` when extending `React.PureComponent`
|
|
426
426
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md
|
|
427
|
-
|
|
427
|
+
"react/no-redundant-should-component-update": "error",
|
|
428
428
|
|
|
429
429
|
// Disallow usage of the return value of `ReactDOM.render`
|
|
430
430
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
431
|
-
|
|
431
|
+
"react/no-render-return-value": "error",
|
|
432
432
|
|
|
433
433
|
// Disallow usage of `setState`
|
|
434
434
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
|
|
435
|
-
|
|
435
|
+
"react/no-set-state": "off",
|
|
436
436
|
|
|
437
437
|
// Disallow using string references
|
|
438
438
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
439
|
-
|
|
439
|
+
"react/no-string-refs": "error",
|
|
440
440
|
|
|
441
441
|
// Disallow `this` from being used in stateless functional components
|
|
442
442
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
|
|
443
|
-
|
|
443
|
+
"react/no-this-in-sfc": "error",
|
|
444
444
|
|
|
445
445
|
// Disallow common typos
|
|
446
446
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-typos.md
|
|
447
|
-
|
|
447
|
+
"react/no-typos": "error",
|
|
448
448
|
|
|
449
449
|
// Disallow unescaped HTML entities from appearing in markup
|
|
450
450
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
451
|
-
|
|
451
|
+
"react/no-unescaped-entities": "off",
|
|
452
452
|
|
|
453
453
|
// Disallow usage of unknown DOM property
|
|
454
454
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
455
|
-
|
|
455
|
+
"react/no-unknown-property": "error",
|
|
456
456
|
|
|
457
457
|
// Disallow usage of unsafe lifecycle methods
|
|
458
458
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
|
|
459
|
-
|
|
459
|
+
"react/no-unsafe": "off",
|
|
460
460
|
|
|
461
461
|
// Disallow creating unstable components inside components
|
|
462
462
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
463
|
-
|
|
463
|
+
"react/no-unstable-nested-components": "error",
|
|
464
464
|
|
|
465
465
|
// Disallow declaring unused methods of component class
|
|
466
466
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md
|
|
467
|
-
|
|
467
|
+
"react/no-unused-class-component-methods": "error",
|
|
468
468
|
|
|
469
469
|
// Disallow definitions of unused `propTypes`
|
|
470
470
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
471
|
-
|
|
472
|
-
|
|
471
|
+
"react/no-unused-prop-types": [
|
|
472
|
+
"error",
|
|
473
473
|
{
|
|
474
474
|
customValidators: [],
|
|
475
475
|
skipShapeProps: true,
|
|
@@ -478,32 +478,32 @@ export const reactRules = {
|
|
|
478
478
|
|
|
479
479
|
// Disallow definitions of unused state
|
|
480
480
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
|
|
481
|
-
|
|
481
|
+
"react/no-unused-state": "error",
|
|
482
482
|
|
|
483
483
|
// Disallow usage of `setState` in `componentWillUpdate`
|
|
484
484
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
485
|
-
|
|
485
|
+
"react/no-will-update-set-state": "error",
|
|
486
486
|
|
|
487
487
|
// Enforce ES5 or ES6 class for React Components
|
|
488
488
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
489
|
-
|
|
489
|
+
"react/prefer-es6-class": ["error", "always"],
|
|
490
490
|
|
|
491
491
|
// Prefer exact `proptype` definitions
|
|
492
492
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md
|
|
493
|
-
|
|
493
|
+
"react/prefer-exact-props": "error",
|
|
494
494
|
|
|
495
495
|
// Enforce that props are read-only
|
|
496
496
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
|
|
497
|
-
|
|
497
|
+
"react/prefer-read-only-props": "off",
|
|
498
498
|
|
|
499
499
|
// Enforce stateless components to be written as a pure `function`
|
|
500
500
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
501
|
-
|
|
501
|
+
"react/prefer-stateless-function": ["error", { ignorePureComponents: true }],
|
|
502
502
|
|
|
503
503
|
// Disallow missing props validation in a React component definition
|
|
504
504
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md
|
|
505
|
-
|
|
506
|
-
|
|
505
|
+
"react/prop-types": [
|
|
506
|
+
"error",
|
|
507
507
|
{
|
|
508
508
|
ignore: [],
|
|
509
509
|
customValidators: [],
|
|
@@ -513,12 +513,12 @@ export const reactRules = {
|
|
|
513
513
|
|
|
514
514
|
// Disallow missing `React` when using JSX
|
|
515
515
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
|
|
516
|
-
|
|
516
|
+
"react/react-in-jsx-scope": "off",
|
|
517
517
|
|
|
518
518
|
// Enforce a `defaultProps` definition for every prop that is not a required prop
|
|
519
519
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
520
|
-
|
|
521
|
-
|
|
520
|
+
"react/require-default-props": [
|
|
521
|
+
"error",
|
|
522
522
|
{
|
|
523
523
|
forbidDefaultForRequired: true,
|
|
524
524
|
},
|
|
@@ -526,76 +526,76 @@ export const reactRules = {
|
|
|
526
526
|
|
|
527
527
|
// Enforce React components to have a `shouldComponentUpdate` method
|
|
528
528
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
|
|
529
|
-
|
|
529
|
+
"react/require-optimization": ["off", { allowDecorators: [] }],
|
|
530
530
|
|
|
531
531
|
// Enforce ES5 or ES6 class for returning value in `render` function
|
|
532
532
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
|
533
|
-
|
|
533
|
+
"react/require-render-return": "error",
|
|
534
534
|
|
|
535
535
|
// Disallow extra closing tags for components without children
|
|
536
536
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
537
|
-
|
|
537
|
+
"react/self-closing-comp": "error",
|
|
538
538
|
|
|
539
539
|
// Enforce component methods order
|
|
540
540
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
|
|
541
|
-
|
|
542
|
-
|
|
541
|
+
"react/sort-comp": [
|
|
542
|
+
"error",
|
|
543
543
|
{
|
|
544
544
|
order: [
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
545
|
+
"static-variables",
|
|
546
|
+
"static-methods",
|
|
547
|
+
"instance-variables",
|
|
548
|
+
"lifecycle",
|
|
549
|
+
"/^handle.+$/",
|
|
550
|
+
"/^on.+$/",
|
|
551
|
+
"getters",
|
|
552
|
+
"setters",
|
|
553
|
+
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
|
|
554
|
+
"instance-methods",
|
|
555
|
+
"everything-else",
|
|
556
|
+
"rendering",
|
|
557
557
|
],
|
|
558
558
|
groups: {
|
|
559
559
|
lifecycle: [
|
|
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
|
-
|
|
560
|
+
"displayName",
|
|
561
|
+
"propTypes",
|
|
562
|
+
"contextTypes",
|
|
563
|
+
"childContextTypes",
|
|
564
|
+
"mixins",
|
|
565
|
+
"statics",
|
|
566
|
+
"defaultProps",
|
|
567
|
+
"constructor",
|
|
568
|
+
"getDefaultProps",
|
|
569
|
+
"getInitialState",
|
|
570
|
+
"state",
|
|
571
|
+
"getChildContext",
|
|
572
|
+
"getDerivedStateFromProps",
|
|
573
|
+
"componentWillMount",
|
|
574
|
+
"UNSAFE_componentWillMount",
|
|
575
|
+
"componentDidMount",
|
|
576
|
+
"componentWillReceiveProps",
|
|
577
|
+
"UNSAFE_componentWillReceiveProps",
|
|
578
|
+
"shouldComponentUpdate",
|
|
579
|
+
"componentWillUpdate",
|
|
580
|
+
"UNSAFE_componentWillUpdate",
|
|
581
|
+
"getSnapshotBeforeUpdate",
|
|
582
|
+
"componentDidUpdate",
|
|
583
|
+
"componentDidCatch",
|
|
584
|
+
"componentWillUnmount",
|
|
585
585
|
],
|
|
586
|
-
rendering: [
|
|
586
|
+
rendering: ["/^render.+$/", "render"],
|
|
587
587
|
},
|
|
588
588
|
},
|
|
589
589
|
],
|
|
590
590
|
|
|
591
591
|
// Enforce defaultProps declarations alphabetical sorting
|
|
592
592
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-default-props.md
|
|
593
|
-
|
|
593
|
+
"react/sort-default-props": "off",
|
|
594
594
|
|
|
595
595
|
// Enforce propTypes declarations alphabetical sorting
|
|
596
596
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
|
|
597
|
-
|
|
598
|
-
|
|
597
|
+
"react/sort-prop-types": [
|
|
598
|
+
"off",
|
|
599
599
|
{
|
|
600
600
|
ignoreCase: true,
|
|
601
601
|
callbacksLast: false,
|
|
@@ -606,55 +606,55 @@ export const reactRules = {
|
|
|
606
606
|
|
|
607
607
|
// Enforce class component state initialization style
|
|
608
608
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
|
|
609
|
-
|
|
609
|
+
"react/state-in-constructor": ["error", "always"],
|
|
610
610
|
|
|
611
611
|
// Enforces where React component static properties should be positioned
|
|
612
612
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
|
|
613
|
-
|
|
613
|
+
"react/static-property-placement": ["error", "property assignment"],
|
|
614
614
|
|
|
615
615
|
// Enforce `style` prop value is an object
|
|
616
616
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
|
|
617
|
-
|
|
617
|
+
"react/style-prop-object": "error",
|
|
618
618
|
|
|
619
619
|
// Disallow void DOM elements (e.g. `<img />`, `<br />`) from receiving children
|
|
620
620
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
|
|
621
|
-
|
|
621
|
+
"react/void-dom-elements-no-children": "error",
|
|
622
622
|
|
|
623
623
|
// eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hook
|
|
624
624
|
|
|
625
625
|
// Enforce Rules of Hooks
|
|
626
626
|
// https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
627
627
|
// https://react.dev/reference/rules/rules-of-hooks
|
|
628
|
-
|
|
628
|
+
"react-hooks/rules-of-hooks": "error",
|
|
629
629
|
|
|
630
630
|
// Verify the list of the dependencies for Hooks like `useEffect` and similar
|
|
631
631
|
// https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
632
632
|
// https://github.com/facebook/react/issues/14920
|
|
633
|
-
|
|
633
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
634
634
|
},
|
|
635
635
|
settings: {
|
|
636
636
|
react: {
|
|
637
|
-
pragma:
|
|
638
|
-
version:
|
|
637
|
+
pragma: "React",
|
|
638
|
+
version: "detect",
|
|
639
639
|
},
|
|
640
|
-
|
|
640
|
+
"import/resolver": {
|
|
641
641
|
node: {
|
|
642
|
-
extensions: [
|
|
642
|
+
extensions: [".js", ".jsx"],
|
|
643
643
|
},
|
|
644
644
|
},
|
|
645
645
|
propWrapperFunctions: [
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
646
|
+
"forbidExtraProps", // https://www.npmjs.com/package/airbnb-prop-types
|
|
647
|
+
"exact", // https://www.npmjs.com/package/prop-types-exact
|
|
648
|
+
"Object.freeze", // https://tc39.github.io/ecma262/#sec-object.freeze
|
|
649
649
|
],
|
|
650
650
|
},
|
|
651
651
|
};
|
|
652
652
|
|
|
653
653
|
export const reactTypescriptRules = {
|
|
654
654
|
settings: {
|
|
655
|
-
|
|
655
|
+
"import/resolver": {
|
|
656
656
|
node: {
|
|
657
|
-
extensions: [
|
|
657
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
658
658
|
},
|
|
659
659
|
},
|
|
660
660
|
},
|
|
@@ -668,14 +668,14 @@ export const reactTypescriptRules = {
|
|
|
668
668
|
|
|
669
669
|
// import/extensions
|
|
670
670
|
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
671
|
+
"import/extensions": [
|
|
672
|
+
"error",
|
|
673
|
+
"ignorePackages",
|
|
674
674
|
{
|
|
675
|
-
js:
|
|
676
|
-
jsx:
|
|
677
|
-
ts:
|
|
678
|
-
tsx:
|
|
675
|
+
js: "never",
|
|
676
|
+
jsx: "never",
|
|
677
|
+
ts: "never",
|
|
678
|
+
tsx: "never",
|
|
679
679
|
},
|
|
680
680
|
],
|
|
681
681
|
|
|
@@ -683,14 +683,14 @@ export const reactTypescriptRules = {
|
|
|
683
683
|
|
|
684
684
|
// Enforce a defaultProps definition for every prop that is not a required prop
|
|
685
685
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
686
|
-
|
|
686
|
+
"react/require-default-props": "off",
|
|
687
687
|
|
|
688
688
|
// Disallow file extensions that may contain JSX
|
|
689
689
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
"react/jsx-filename-extension": [
|
|
691
|
+
"error",
|
|
692
692
|
{
|
|
693
|
-
extensions: [
|
|
693
|
+
extensions: [".jsx", ".tsx"],
|
|
694
694
|
},
|
|
695
695
|
],
|
|
696
696
|
},
|
|
@@ -698,164 +698,164 @@ export const reactTypescriptRules = {
|
|
|
698
698
|
|
|
699
699
|
export const reactTestRules = {
|
|
700
700
|
plugins: {
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
"testing-library": testingLibraryPlugin,
|
|
702
|
+
"jest-dom": jestDom,
|
|
703
703
|
},
|
|
704
704
|
rules: {
|
|
705
705
|
// eslint-plugin-jest-dom https://github.com/testing-library/eslint-plugin-jest-dom
|
|
706
706
|
|
|
707
707
|
// Prefer toBeChecked over checking attributes
|
|
708
708
|
// Prefer `toBeChecked` over checking attributes
|
|
709
|
-
|
|
709
|
+
"jest-dom/prefer-checked": "error",
|
|
710
710
|
|
|
711
711
|
// Prefer toBeEmpty over checking innerHTML
|
|
712
712
|
// Prefer `toBeEmpty` over checking `innerHTML`
|
|
713
|
-
|
|
713
|
+
"jest-dom/prefer-empty": "error",
|
|
714
714
|
|
|
715
715
|
// Prefer toBeDisabled or toBeEnabled over checking attributes
|
|
716
716
|
// Prefer `toBeDisabled` or `toBeEnabled` over checking attributes
|
|
717
|
-
|
|
717
|
+
"jest-dom/prefer-enabled-disabled": "error",
|
|
718
718
|
|
|
719
719
|
// Prefer toHaveFocus over checking document.activeElement
|
|
720
720
|
// Prefer `toHaveFocus` over checking `document.activeElement`
|
|
721
|
-
|
|
721
|
+
"jest-dom/prefer-focus": "error",
|
|
722
722
|
|
|
723
723
|
// Prefer .toBeInTheDocument() for asserting the existence of a DOM node
|
|
724
724
|
// Prefer `.toBeInTheDocument()` for asserting the existence of a DOM node
|
|
725
|
-
|
|
725
|
+
"jest-dom/prefer-in-document": "error",
|
|
726
726
|
|
|
727
727
|
// Prefer toBeRequired over checking properties
|
|
728
728
|
// Prefer `toBeRequired` over checking properties
|
|
729
|
-
|
|
729
|
+
"jest-dom/prefer-required": "error",
|
|
730
730
|
|
|
731
731
|
// Prefer `toHaveAttribute` over checking `getAttribute`/`hasAttribute`
|
|
732
732
|
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-attribute.md
|
|
733
|
-
|
|
733
|
+
"jest-dom/prefer-to-have-attribute": "error",
|
|
734
734
|
|
|
735
735
|
// Prefer `toHaveClass` over checking element `className`
|
|
736
736
|
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-class.md
|
|
737
|
-
|
|
737
|
+
"jest-dom/prefer-to-have-class": "error",
|
|
738
738
|
|
|
739
739
|
// Prefer `toHaveStyle` over checking element `style`
|
|
740
740
|
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-style.md
|
|
741
|
-
|
|
741
|
+
"jest-dom/prefer-to-have-style": "error",
|
|
742
742
|
|
|
743
743
|
// Prefer `toHaveTextContent` over checking `element.textContent`
|
|
744
744
|
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-text-content.md
|
|
745
|
-
|
|
745
|
+
"jest-dom/prefer-to-have-text-content": "error",
|
|
746
746
|
|
|
747
747
|
// Prefer `toHaveValue` over checking `element.value`
|
|
748
748
|
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-value.md
|
|
749
|
-
|
|
749
|
+
"jest-dom/prefer-to-have-value": "error",
|
|
750
750
|
|
|
751
751
|
// eslint-plugin-testing-library https://github.com/testing-library/eslint-plugin-testing-library
|
|
752
752
|
|
|
753
753
|
// Enforce promises from async event methods are handled
|
|
754
754
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-events.md
|
|
755
|
-
|
|
755
|
+
"testing-library/await-async-events": "off",
|
|
756
756
|
|
|
757
757
|
// Enforce promises from async queries to be handled
|
|
758
758
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-queries.md
|
|
759
|
-
|
|
759
|
+
"testing-library/await-async-queries": "error",
|
|
760
760
|
|
|
761
761
|
// Enforce promises from async utils to be awaited properly
|
|
762
762
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-utils.md
|
|
763
|
-
|
|
763
|
+
"testing-library/await-async-utils": "error",
|
|
764
764
|
|
|
765
765
|
// Ensures consistent usage of data-testid
|
|
766
766
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md
|
|
767
|
-
|
|
767
|
+
"testing-library/consistent-data-testid": "off",
|
|
768
768
|
|
|
769
769
|
// Disallow unnecessary await for sync events
|
|
770
770
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-events.md
|
|
771
|
-
|
|
771
|
+
"testing-library/no-await-sync-events": "off",
|
|
772
772
|
|
|
773
773
|
// Disallow unnecessary await for sync queries
|
|
774
774
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-queries.md
|
|
775
|
-
|
|
775
|
+
"testing-library/no-await-sync-queries": "error",
|
|
776
776
|
|
|
777
777
|
// Disallow the use of container methods
|
|
778
778
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-container.md
|
|
779
|
-
|
|
779
|
+
"testing-library/no-container": "error",
|
|
780
780
|
|
|
781
781
|
// Disallow the use of debugging utilities like debug
|
|
782
782
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-debugging-utils.md
|
|
783
|
-
|
|
783
|
+
"testing-library/no-debugging-utils": "error",
|
|
784
784
|
|
|
785
785
|
// Disallow importing from DOM Testing Library
|
|
786
786
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-dom-import.md
|
|
787
|
-
|
|
787
|
+
"testing-library/no-dom-import": ["error", "react"],
|
|
788
788
|
|
|
789
789
|
// Disallow the use of the global RegExp flag (/g) in queries
|
|
790
790
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-global-regexp-flag-in-query.md
|
|
791
|
-
|
|
791
|
+
"testing-library/no-global-regexp-flag-in-query": "off",
|
|
792
792
|
|
|
793
793
|
// Disallow the use of cleanup
|
|
794
794
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-manual-cleanup.md
|
|
795
|
-
|
|
795
|
+
"testing-library/no-manual-cleanup": "off",
|
|
796
796
|
|
|
797
797
|
// Disallow direct Node access
|
|
798
798
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-node-access.md
|
|
799
|
-
|
|
799
|
+
"testing-library/no-node-access": "error",
|
|
800
800
|
|
|
801
801
|
// Disallow the use of promises passed to a `fireEvent` method
|
|
802
802
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-promise-in-fire-event.md
|
|
803
|
-
|
|
803
|
+
"testing-library/no-promise-in-fire-event": "error",
|
|
804
804
|
|
|
805
805
|
// Disallow the use of `render` in testing frameworks setup functions
|
|
806
806
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-render-in-lifecycle.md
|
|
807
|
-
|
|
807
|
+
"testing-library/no-render-in-lifecycle": "error",
|
|
808
808
|
|
|
809
809
|
// Disallow wrapping Testing Library utils or empty callbacks in `act`
|
|
810
810
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-unnecessary-act.md
|
|
811
|
-
|
|
811
|
+
"testing-library/no-unnecessary-act": "error",
|
|
812
812
|
|
|
813
813
|
// Disallow the use of multiple `expect` calls inside `waitFor`
|
|
814
814
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-multiple-assertions.md
|
|
815
|
-
|
|
815
|
+
"testing-library/no-wait-for-multiple-assertions": "error",
|
|
816
816
|
|
|
817
817
|
// Disallow the use of side effects in `waitFor`
|
|
818
818
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-side-effects.md
|
|
819
|
-
|
|
819
|
+
"testing-library/no-wait-for-side-effects": "error",
|
|
820
820
|
|
|
821
821
|
// Ensures no snapshot is generated inside of a `waitFor` call
|
|
822
822
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-snapshot.md
|
|
823
|
-
|
|
823
|
+
"testing-library/no-wait-for-snapshot": "error",
|
|
824
824
|
|
|
825
825
|
// Suggest using explicit assertions rather than standalone queries
|
|
826
826
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-explicit-assert.md
|
|
827
|
-
|
|
827
|
+
"testing-library/prefer-explicit-assert": "off",
|
|
828
828
|
|
|
829
829
|
// Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements
|
|
830
830
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-find-by.md
|
|
831
|
-
|
|
831
|
+
"testing-library/prefer-find-by": "error",
|
|
832
832
|
|
|
833
833
|
// Suggest using implicit assertions for `getBy*` & `findBy*` queries
|
|
834
834
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-implicit-assert.md
|
|
835
|
-
|
|
835
|
+
"testing-library/prefer-implicit-assert": "off",
|
|
836
836
|
|
|
837
837
|
// Ensure appropriate `get*`/`query*` queries are used with their respective matchers
|
|
838
838
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-presence-queries.md
|
|
839
|
-
|
|
839
|
+
"testing-library/prefer-presence-queries": "error",
|
|
840
840
|
|
|
841
841
|
// Suggest using `queryBy*` queries when waiting for disappearance
|
|
842
842
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-by-disappearance.md
|
|
843
|
-
|
|
843
|
+
"testing-library/prefer-query-by-disappearance": "error",
|
|
844
844
|
|
|
845
845
|
// Ensure the configured `get*`/`query*` query is used with the corresponding matchers
|
|
846
846
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-matchers.md
|
|
847
|
-
|
|
847
|
+
"testing-library/prefer-query-matchers": "error",
|
|
848
848
|
|
|
849
849
|
// Suggest using `screen` while querying
|
|
850
850
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md
|
|
851
|
-
|
|
851
|
+
"testing-library/prefer-screen-queries": "error",
|
|
852
852
|
|
|
853
853
|
// Suggest using `userEvent` over `fireEvent` for simulating user interactions
|
|
854
854
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-user-event.md
|
|
855
|
-
|
|
855
|
+
"testing-library/prefer-user-event": "off",
|
|
856
856
|
|
|
857
857
|
// Enforce a valid naming for return value from render
|
|
858
858
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
|
|
859
|
-
|
|
859
|
+
"testing-library/render-result-naming-convention": "error",
|
|
860
860
|
},
|
|
861
861
|
};
|