@qlik/eslint-config 0.8.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -80
- package/package.json +37 -43
- package/src/configs/cjs.js +45 -0
- package/src/configs/esm.js +43 -0
- package/src/configs/jest.js +24 -0
- package/src/configs/playwright.js +19 -0
- package/src/configs/react.js +75 -0
- package/src/configs/recommended.js +64 -0
- package/src/configs/rules/eslint-core.js +970 -0
- package/src/configs/rules/import-x.js +159 -0
- package/src/configs/rules/index.js +17 -0
- package/src/configs/rules/node.js +10 -0
- package/src/configs/rules/react-a11y.js +232 -0
- package/src/configs/rules/react-hooks.js +16 -0
- package/src/configs/rules/react.js +479 -0
- package/src/configs/rules/svelte.js +11 -0
- package/src/configs/rules/testing-library.js +74 -0
- package/src/configs/rules/typescript.js +228 -0
- package/src/configs/svelte.js +48 -0
- package/src/configs/vitest.js +36 -0
- package/src/index.d.ts +24 -0
- package/src/index.js +29 -0
- package/src/types/index.ts +52 -0
- package/src/utils/compose.js +62 -0
- package/src/utils/config.js +22 -0
- package/src/utils/merge.js +28 -0
- package/configs/airbnb-base-mod.js +0 -77
- package/configs/airbnb-mod.js +0 -17
- package/configs/airbnb-ts-base-mod.js +0 -37
- package/configs/airbnb-ts-mod.js +0 -17
- package/configs/env.js +0 -11
- package/esm.js +0 -6
- package/index.js +0 -10
- package/jest.js +0 -25
- package/node.js +0 -10
- package/overrides/react.js +0 -27
- package/overrides/sveltejs.js +0 -25
- package/overrides/sveltets.js +0 -32
- package/overrides/ts.js +0 -23
- package/playwright.js +0 -12
- package/react-svelte.js +0 -6
- package/react.js +0 -3
- package/svelte-js.js +0 -6
- package/svelte.js +0 -6
- package/vitest.js +0 -13
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
|
|
5
|
+
*/
|
|
6
|
+
const rules = {
|
|
7
|
+
"class-methods-use-this": [
|
|
8
|
+
"warn",
|
|
9
|
+
{
|
|
10
|
+
exceptMethods: [
|
|
11
|
+
"render",
|
|
12
|
+
"getInitialState",
|
|
13
|
+
"getDefaultProps",
|
|
14
|
+
"getChildContext",
|
|
15
|
+
"componentWillMount",
|
|
16
|
+
"UNSAFE_componentWillMount",
|
|
17
|
+
"componentDidMount",
|
|
18
|
+
"componentWillReceiveProps",
|
|
19
|
+
"UNSAFE_componentWillReceiveProps",
|
|
20
|
+
"shouldComponentUpdate",
|
|
21
|
+
"componentWillUpdate",
|
|
22
|
+
"UNSAFE_componentWillUpdate",
|
|
23
|
+
"componentDidUpdate",
|
|
24
|
+
"componentWillUnmount",
|
|
25
|
+
"componentDidCatch",
|
|
26
|
+
"getSnapshotBeforeUpdate",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
// Forbid certain propTypes (any, array, object)
|
|
32
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
|
|
33
|
+
"react/forbid-prop-types": [
|
|
34
|
+
"error",
|
|
35
|
+
{
|
|
36
|
+
forbid: ["any", "array", "object"],
|
|
37
|
+
checkContextTypes: true,
|
|
38
|
+
checkChildContextTypes: true,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
// Enforce boolean attributes notation in JSX
|
|
43
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
44
|
+
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
45
|
+
|
|
46
|
+
// Validate closing bracket location in JSX
|
|
47
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
|
|
48
|
+
"react/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
49
|
+
|
|
50
|
+
// Validate closing tag location in JSX
|
|
51
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
52
|
+
"react/jsx-closing-tag-location": "error",
|
|
53
|
+
|
|
54
|
+
// Enforce or disallow spaces inside of curly braces in JSX attributes
|
|
55
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
|
|
56
|
+
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
57
|
+
|
|
58
|
+
// Validate props indentation in JSX
|
|
59
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
60
|
+
"react/jsx-indent-props": ["error", 2],
|
|
61
|
+
|
|
62
|
+
// Limit maximum of props on a single line in JSX
|
|
63
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
64
|
+
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
65
|
+
|
|
66
|
+
// Prevent usage of .bind() in JSX props
|
|
67
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
68
|
+
"react/jsx-no-bind": [
|
|
69
|
+
"error",
|
|
70
|
+
{
|
|
71
|
+
ignoreRefs: true,
|
|
72
|
+
allowArrowFunctions: true,
|
|
73
|
+
allowFunctions: false,
|
|
74
|
+
allowBind: false,
|
|
75
|
+
ignoreDOMComponents: true,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
|
|
79
|
+
// Prevent duplicate props in JSX
|
|
80
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
|
|
81
|
+
"react/jsx-no-duplicate-props": ["error", { ignoreCase: true }],
|
|
82
|
+
|
|
83
|
+
// Disallow undeclared variables in JSX
|
|
84
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
|
|
85
|
+
"react/jsx-no-undef": "error",
|
|
86
|
+
|
|
87
|
+
// Enforce PascalCase for user-defined JSX components
|
|
88
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
89
|
+
"react/jsx-pascal-case": [
|
|
90
|
+
"error",
|
|
91
|
+
{
|
|
92
|
+
allowAllCaps: true,
|
|
93
|
+
ignore: [],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
|
|
97
|
+
// Prevent React to be incorrectly marked as unused
|
|
98
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
|
|
99
|
+
"react/jsx-uses-react": "off",
|
|
100
|
+
|
|
101
|
+
// Prevent variables used in JSX to be incorrectly marked as unused
|
|
102
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
|
103
|
+
"react/jsx-uses-vars": "error",
|
|
104
|
+
|
|
105
|
+
// Prevent usage of dangerous JSX properties
|
|
106
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md
|
|
107
|
+
"react/no-danger": "warn",
|
|
108
|
+
|
|
109
|
+
// Prevent usage of deprecated methods
|
|
110
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
|
111
|
+
"react/no-deprecated": ["error"],
|
|
112
|
+
|
|
113
|
+
// Prevent usage of setState in componentDidUpdate
|
|
114
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
|
115
|
+
"react/no-did-update-set-state": "error",
|
|
116
|
+
|
|
117
|
+
// Prevent usage of setState in componentWillUpdate
|
|
118
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
|
|
119
|
+
"react/no-will-update-set-state": "error",
|
|
120
|
+
|
|
121
|
+
// Prevent usage of isMounted
|
|
122
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
|
|
123
|
+
"react/no-is-mounted": "error",
|
|
124
|
+
|
|
125
|
+
// Prevent using string references
|
|
126
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
|
|
127
|
+
"react/no-string-refs": "error",
|
|
128
|
+
|
|
129
|
+
// Prevent usage of unknown DOM property
|
|
130
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
|
|
131
|
+
"react/no-unknown-property": "error",
|
|
132
|
+
|
|
133
|
+
// Require ES6 class declarations over React.createClass
|
|
134
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
|
|
135
|
+
"react/prefer-es6-class": ["error", "always"],
|
|
136
|
+
|
|
137
|
+
// Require stateless functions when not using lifecycle methods, setState or ref
|
|
138
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
|
|
139
|
+
"react/prefer-stateless-function": ["error", { ignorePureComponents: true }],
|
|
140
|
+
|
|
141
|
+
// Prevent missing props validation in a React component definition
|
|
142
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md
|
|
143
|
+
"react/prop-types": [
|
|
144
|
+
"error",
|
|
145
|
+
{
|
|
146
|
+
ignore: [],
|
|
147
|
+
customValidators: [],
|
|
148
|
+
skipUndeclared: false,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
|
|
152
|
+
// Prevent missing React when using JSX
|
|
153
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
|
|
154
|
+
"react/react-in-jsx-scope": "off",
|
|
155
|
+
|
|
156
|
+
// Require render() methods to return something
|
|
157
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
|
158
|
+
"react/require-render-return": "error",
|
|
159
|
+
|
|
160
|
+
// Prevent extra closing tags for components without children
|
|
161
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
162
|
+
"react/self-closing-comp": "error",
|
|
163
|
+
|
|
164
|
+
// Enforce component methods order
|
|
165
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
|
|
166
|
+
"react/sort-comp": [
|
|
167
|
+
"error",
|
|
168
|
+
{
|
|
169
|
+
order: [
|
|
170
|
+
"static-variables",
|
|
171
|
+
"static-methods",
|
|
172
|
+
"instance-variables",
|
|
173
|
+
"lifecycle",
|
|
174
|
+
"/^handle.+$/",
|
|
175
|
+
"/^on.+$/",
|
|
176
|
+
"getters",
|
|
177
|
+
"setters",
|
|
178
|
+
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
|
|
179
|
+
"instance-methods",
|
|
180
|
+
"everything-else",
|
|
181
|
+
"rendering",
|
|
182
|
+
],
|
|
183
|
+
groups: {
|
|
184
|
+
lifecycle: [
|
|
185
|
+
"displayName",
|
|
186
|
+
"propTypes",
|
|
187
|
+
"contextTypes",
|
|
188
|
+
"childContextTypes",
|
|
189
|
+
"mixins",
|
|
190
|
+
"statics",
|
|
191
|
+
"defaultProps",
|
|
192
|
+
"constructor",
|
|
193
|
+
"getDefaultProps",
|
|
194
|
+
"getInitialState",
|
|
195
|
+
"state",
|
|
196
|
+
"getChildContext",
|
|
197
|
+
"getDerivedStateFromProps",
|
|
198
|
+
"componentWillMount",
|
|
199
|
+
"UNSAFE_componentWillMount",
|
|
200
|
+
"componentDidMount",
|
|
201
|
+
"componentWillReceiveProps",
|
|
202
|
+
"UNSAFE_componentWillReceiveProps",
|
|
203
|
+
"shouldComponentUpdate",
|
|
204
|
+
"componentWillUpdate",
|
|
205
|
+
"UNSAFE_componentWillUpdate",
|
|
206
|
+
"getSnapshotBeforeUpdate",
|
|
207
|
+
"componentDidUpdate",
|
|
208
|
+
"componentDidCatch",
|
|
209
|
+
"componentWillUnmount",
|
|
210
|
+
],
|
|
211
|
+
rendering: ["/^render.+$/", "render"],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
|
|
216
|
+
// Prevent missing parentheses around multilines JSX
|
|
217
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
|
218
|
+
"react/jsx-wrap-multilines": [
|
|
219
|
+
"error",
|
|
220
|
+
{
|
|
221
|
+
declaration: "parens-new-line",
|
|
222
|
+
assignment: "parens-new-line",
|
|
223
|
+
return: "parens-new-line",
|
|
224
|
+
arrow: "parens-new-line",
|
|
225
|
+
condition: "parens-new-line",
|
|
226
|
+
logical: "parens-new-line",
|
|
227
|
+
prop: "ignore",
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
|
|
231
|
+
// Require that the first prop in a JSX element be on a new line when the element is multiline
|
|
232
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
233
|
+
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
234
|
+
|
|
235
|
+
// Stylistic, Prettier handles this.
|
|
236
|
+
// Enforce spacing around jsx equals signs
|
|
237
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
|
238
|
+
"react/jsx-equals-spacing": "off",
|
|
239
|
+
|
|
240
|
+
// Stylistic, Prettier handles this.
|
|
241
|
+
// Enforce JSX indentation
|
|
242
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
|
|
243
|
+
"react/jsx-indent": "off",
|
|
244
|
+
|
|
245
|
+
// Disallow target="_blank" on links
|
|
246
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
247
|
+
"react/jsx-no-target-blank": ["error", { enforceDynamicLinks: "always" }],
|
|
248
|
+
|
|
249
|
+
// only .jsx files may have JSX
|
|
250
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
251
|
+
"react/jsx-filename-extension": ["error", { extensions: [".jsx"] }],
|
|
252
|
+
|
|
253
|
+
// prevent accidental JS comments from being injected into JSX as text
|
|
254
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
255
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
256
|
+
|
|
257
|
+
// disallow using React.render/ReactDOM.render's return value
|
|
258
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
|
259
|
+
"react/no-render-return-value": "error",
|
|
260
|
+
|
|
261
|
+
// warn against using findDOMNode()
|
|
262
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
|
263
|
+
"react/no-find-dom-node": "error",
|
|
264
|
+
|
|
265
|
+
// Prevent problem with children and props.dangerouslySetInnerHTML
|
|
266
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
|
|
267
|
+
"react/no-danger-with-children": "error",
|
|
268
|
+
|
|
269
|
+
// Prevent unused propType definitions
|
|
270
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
|
|
271
|
+
"react/no-unused-prop-types": [
|
|
272
|
+
"error",
|
|
273
|
+
{
|
|
274
|
+
customValidators: [],
|
|
275
|
+
skipShapeProps: true,
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
|
|
279
|
+
// Require style prop value be an object or var
|
|
280
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
|
|
281
|
+
"react/style-prop-object": "error",
|
|
282
|
+
|
|
283
|
+
// Prevent invalid characters from appearing in markup
|
|
284
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
|
|
285
|
+
"react/no-unescaped-entities": "error",
|
|
286
|
+
|
|
287
|
+
// Prevent passing of children as props
|
|
288
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
|
|
289
|
+
"react/no-children-prop": "error",
|
|
290
|
+
|
|
291
|
+
// Validate whitespace in and around the JSX opening and closing brackets
|
|
292
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
|
|
293
|
+
"react/jsx-tag-spacing": [
|
|
294
|
+
"error",
|
|
295
|
+
{
|
|
296
|
+
closingSlash: "never",
|
|
297
|
+
beforeSelfClosing: "always",
|
|
298
|
+
afterOpening: "never",
|
|
299
|
+
beforeClosing: "never",
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
|
|
303
|
+
// Prevent usage of Array index in keys
|
|
304
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
305
|
+
"react/no-array-index-key": "error",
|
|
306
|
+
|
|
307
|
+
// We dont use `.defaultProps` any more, we use fallbacks on props (`{ foo = "bar" }`)
|
|
308
|
+
// Enforce a defaultProps definition for every prop that is not a required prop
|
|
309
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
310
|
+
"react/require-default-props": "off",
|
|
311
|
+
|
|
312
|
+
// Forbids using non-exported propTypes
|
|
313
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
|
|
314
|
+
// this is intentionally set to "warn". it would be "error",
|
|
315
|
+
// but it's only critical if you're stripping propTypes in production.
|
|
316
|
+
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }],
|
|
317
|
+
|
|
318
|
+
// Prevent void DOM elements from receiving children
|
|
319
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
|
|
320
|
+
"react/void-dom-elements-no-children": "error",
|
|
321
|
+
|
|
322
|
+
// Enforce all defaultProps have a corresponding non-required PropType
|
|
323
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
|
|
324
|
+
"react/default-props-match-prop-types": ["error", { allowRequiredDefaults: false }],
|
|
325
|
+
|
|
326
|
+
// Prevent usage of shouldComponentUpdate when extending React.PureComponent
|
|
327
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md
|
|
328
|
+
"react/no-redundant-should-component-update": "error",
|
|
329
|
+
|
|
330
|
+
// Prevent unused state values
|
|
331
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/pull/1103/
|
|
332
|
+
"react/no-unused-state": "error",
|
|
333
|
+
|
|
334
|
+
// Prevents common casing typos
|
|
335
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-typos.md
|
|
336
|
+
"react/no-typos": "error",
|
|
337
|
+
|
|
338
|
+
// Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children
|
|
339
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
340
|
+
"react/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }],
|
|
341
|
+
|
|
342
|
+
// Stylistic, Prettier handles this.
|
|
343
|
+
// One JSX Element Per Line
|
|
344
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
345
|
+
"react/jsx-one-expression-per-line": "off",
|
|
346
|
+
|
|
347
|
+
// Enforce consistent usage of destructuring assignment of props, state, and context
|
|
348
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
|
|
349
|
+
"react/destructuring-assignment": ["error", "always"],
|
|
350
|
+
|
|
351
|
+
// Prevent using this.state within a this.setState
|
|
352
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md
|
|
353
|
+
"react/no-access-state-in-setstate": "error",
|
|
354
|
+
|
|
355
|
+
// Prevent usage of button elements without an explicit type attribute
|
|
356
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
357
|
+
"react/button-has-type": [
|
|
358
|
+
"error",
|
|
359
|
+
{
|
|
360
|
+
button: true,
|
|
361
|
+
submit: true,
|
|
362
|
+
reset: false,
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
|
|
366
|
+
// Prevent this from being used in stateless functional components
|
|
367
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
|
|
368
|
+
"react/no-this-in-sfc": "error",
|
|
369
|
+
|
|
370
|
+
// Disallow multiple spaces between inline JSX props
|
|
371
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
|
|
372
|
+
"react/jsx-props-no-multi-spaces": "error",
|
|
373
|
+
|
|
374
|
+
// Enforce shorthand or standard form for React fragments
|
|
375
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
376
|
+
"react/jsx-fragments": ["error", "syntax"],
|
|
377
|
+
|
|
378
|
+
// Enforce linebreaks in curly braces in JSX attributes and expressions.
|
|
379
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
380
|
+
"react/jsx-curly-newline": [
|
|
381
|
+
"error",
|
|
382
|
+
{
|
|
383
|
+
multiline: "consistent",
|
|
384
|
+
singleline: "consistent",
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
|
|
388
|
+
// Enforce state initialization style
|
|
389
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
|
|
390
|
+
// TODO: set to "never" once babel-preset-airbnb supports public class fields
|
|
391
|
+
"react/state-in-constructor": ["error", "always"],
|
|
392
|
+
|
|
393
|
+
// Enforces where React component static properties should be positioned
|
|
394
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
|
|
395
|
+
// TODO: set to "static public field" once babel-preset-airbnb supports public class fields
|
|
396
|
+
"react/static-property-placement": ["error", "property assignment"],
|
|
397
|
+
|
|
398
|
+
// This has valid cases but best practice to be explicit about the props
|
|
399
|
+
// Disallow JSX props spreading
|
|
400
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
|
|
401
|
+
"react/jsx-props-no-spreading": [
|
|
402
|
+
"off",
|
|
403
|
+
{
|
|
404
|
+
html: "enforce",
|
|
405
|
+
custom: "enforce",
|
|
406
|
+
explicitSpread: "ignore",
|
|
407
|
+
exceptions: [],
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
|
|
411
|
+
// Prevent usage of `javascript:` URLs
|
|
412
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
|
|
413
|
+
"react/jsx-no-script-url": [
|
|
414
|
+
"error",
|
|
415
|
+
[
|
|
416
|
+
{
|
|
417
|
+
name: "Link",
|
|
418
|
+
props: ["to"],
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
],
|
|
422
|
+
|
|
423
|
+
// Disallow unnecessary fragments
|
|
424
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
425
|
+
"react/jsx-no-useless-fragment": "error",
|
|
426
|
+
|
|
427
|
+
// Stylistic rule
|
|
428
|
+
// Enforce a specific function type for function components
|
|
429
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
|
|
430
|
+
"react/function-component-definition": "off",
|
|
431
|
+
|
|
432
|
+
// Prevent react contexts from taking non-stable values
|
|
433
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
|
|
434
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
435
|
+
|
|
436
|
+
// Prevent creating unstable components inside components
|
|
437
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
438
|
+
"react/no-unstable-nested-components": "error",
|
|
439
|
+
|
|
440
|
+
// Enforce that namespaces are not used in React elements
|
|
441
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-namespace.md
|
|
442
|
+
"react/no-namespace": "error",
|
|
443
|
+
|
|
444
|
+
// Prefer exact proptype definitions
|
|
445
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md
|
|
446
|
+
"react/prefer-exact-props": "error",
|
|
447
|
+
|
|
448
|
+
// Lifecycle methods should be methods on the prototype, not class fields
|
|
449
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-arrow-function-lifecycle.md
|
|
450
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
451
|
+
|
|
452
|
+
// Prevent usage of invalid attributes
|
|
453
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-invalid-html-attribute.md
|
|
454
|
+
"react/no-invalid-html-attribute": "error",
|
|
455
|
+
|
|
456
|
+
// Prevent declaring unused methods of component class
|
|
457
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md
|
|
458
|
+
"react/no-unused-class-component-methods": "error",
|
|
459
|
+
|
|
460
|
+
// Ensure destructuring and symmetric naming of useState hook value and setter variables
|
|
461
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
462
|
+
"react/hook-use-state": "error",
|
|
463
|
+
|
|
464
|
+
// Prevent problematic leaked values from being rendered
|
|
465
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
466
|
+
"react/jsx-no-leaked-render": "error",
|
|
467
|
+
|
|
468
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-object-type-as-default-prop.md
|
|
469
|
+
|
|
470
|
+
"react/no-object-type-as-default-prop": "error",
|
|
471
|
+
|
|
472
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forward-ref-uses-ref.md
|
|
473
|
+
"react/forward-ref-uses-ref": "error",
|
|
474
|
+
|
|
475
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
|
|
476
|
+
"react/jsx-props-no-spread-multi": "error",
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
export default rules;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
|
|
5
|
+
*/
|
|
6
|
+
const rules = {
|
|
7
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-events.md
|
|
8
|
+
"testing-library/await-async-events": ["error", { eventModule: "userEvent" }],
|
|
9
|
+
|
|
10
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-queries.md
|
|
11
|
+
"testing-library/await-async-queries": "error",
|
|
12
|
+
|
|
13
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-utils.md
|
|
14
|
+
"testing-library/await-async-utils": "error",
|
|
15
|
+
|
|
16
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-events.md
|
|
17
|
+
"testing-library/no-await-sync-events": ["error", { eventModules: ["fire-event"] }],
|
|
18
|
+
|
|
19
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-queries.md
|
|
20
|
+
"testing-library/no-await-sync-queries": "error",
|
|
21
|
+
|
|
22
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-container.md
|
|
23
|
+
"testing-library/no-container": "error",
|
|
24
|
+
|
|
25
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-debugging-utils.md
|
|
26
|
+
"testing-library/no-debugging-utils": "warn",
|
|
27
|
+
|
|
28
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-dom-import.md
|
|
29
|
+
"testing-library/no-dom-import": ["error", "react"],
|
|
30
|
+
|
|
31
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-global-regexp-flag-in-query.md
|
|
32
|
+
"testing-library/no-global-regexp-flag-in-query": "error",
|
|
33
|
+
|
|
34
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-manual-cleanup.md
|
|
35
|
+
"testing-library/no-manual-cleanup": "error",
|
|
36
|
+
|
|
37
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-node-access.md
|
|
38
|
+
"testing-library/no-node-access": "error",
|
|
39
|
+
|
|
40
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-promise-in-fire-event.md
|
|
41
|
+
"testing-library/no-promise-in-fire-event": "error",
|
|
42
|
+
|
|
43
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-render-in-lifecycle.md
|
|
44
|
+
"testing-library/no-render-in-lifecycle": "error",
|
|
45
|
+
|
|
46
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-unnecessary-act.md
|
|
47
|
+
"testing-library/no-unnecessary-act": "error",
|
|
48
|
+
|
|
49
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-multiple-assertions.md
|
|
50
|
+
"testing-library/no-wait-for-multiple-assertions": "error",
|
|
51
|
+
|
|
52
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-side-effects.md
|
|
53
|
+
"testing-library/no-wait-for-side-effects": "error",
|
|
54
|
+
|
|
55
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-snapshot.md
|
|
56
|
+
"testing-library/no-wait-for-snapshot": "error",
|
|
57
|
+
|
|
58
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-find-by.md
|
|
59
|
+
"testing-library/prefer-find-by": "error",
|
|
60
|
+
|
|
61
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-presence-queries.md
|
|
62
|
+
"testing-library/prefer-presence-queries": "error",
|
|
63
|
+
|
|
64
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-by-disappearance.md
|
|
65
|
+
"testing-library/prefer-query-by-disappearance": "error",
|
|
66
|
+
|
|
67
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md
|
|
68
|
+
"testing-library/prefer-screen-queries": "error",
|
|
69
|
+
|
|
70
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
|
|
71
|
+
"testing-library/render-result-naming-convention": "error",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default rules;
|