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