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