eslint-config-vylda-vanilla-react 4.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.
@@ -0,0 +1,610 @@
1
+ import globals from 'globals';
2
+ import { INDENT, JSX_MAX_DEPTH } from './constants.mjs';
3
+
4
+ const config = [
5
+ {
6
+ languageOptions: {
7
+ globals: {
8
+ ...globals.browser,
9
+ },
10
+ parserOptions: {
11
+ ecmaFeatures: {
12
+ jsx: true,
13
+ },
14
+ },
15
+ },
16
+ name: 'react/react',
17
+ rules: {
18
+ // Enforces consistent naming for boolean props
19
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md
20
+ 'react/boolean-prop-naming': [
21
+ 'warn',
22
+ {
23
+ message: 'Boolean pros must start with has or is.',
24
+ propTypeNames: ['bool', 'mutuallyExclusiveTrueProps', 'boolean'],
25
+ rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
26
+ },
27
+ ],
28
+
29
+ // Prevent usage of button elements without an explicit type attribute
30
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
31
+ 'react/button-has-type': [
32
+ 'error', {
33
+ button: true,
34
+ reset: false,
35
+ submit: true,
36
+ },
37
+ ],
38
+
39
+ // This rule enforces onChange or readonly attribute for checked property of input elements.
40
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md
41
+ 'react/checked-requires-onchange-or-readonly': [
42
+ 'error',
43
+ {
44
+ ignoreExclusiveCheckedAttribute: false,
45
+ ignoreMissingProperties: false,
46
+ },
47
+ ],
48
+
49
+ // Enforce all defaultProps have a corresponding non-required PropType
50
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
51
+ 'react/default-props-match-prop-types': 'off',
52
+
53
+ // Enforce consistent usage of destructuring assignment of props, state, and context
54
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
55
+ 'react/destructuring-assignment': ['error', 'always'],
56
+
57
+ // Prevent missing displayName in a React component definition
58
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
59
+ 'react/display-name': 'off',
60
+
61
+ // Forbid certain props on Components
62
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
63
+ 'react/forbid-component-props': 'off',
64
+
65
+ // Forbid certain props on DOM Nodes
66
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md
67
+ 'react/forbid-dom-props': 'off',
68
+
69
+ // Forbid certain elements
70
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
71
+ 'react/forbid-elements': 'off',
72
+
73
+ // Forbids using non-exported propTypes
74
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
75
+ 'react/forbid-foreign-prop-types': 'off',
76
+
77
+ // Forbid certain propTypes (any, array, object)
78
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
79
+ 'react/forbid-prop-types': [
80
+ 'error',
81
+ {
82
+ checkChildContextTypes: true,
83
+ checkContextTypes: true,
84
+ forbid: ['any', 'array', 'object'],
85
+ },
86
+ ],
87
+
88
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forward-ref-uses-ref.md
89
+ // TODO: semver-major, enable
90
+ 'react/forward-ref-uses-ref': 'error',
91
+
92
+ // Enforce a specific function type for function components
93
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
94
+ 'react/function-component-definition': [
95
+ 'error',
96
+ {
97
+ namedComponents: ['arrow-function'],
98
+ unnamedComponents: 'arrow-function',
99
+ },
100
+ ],
101
+
102
+ // Ensure destructuring and symmetric naming of useState hook value and setter variables
103
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
104
+ // TODO: semver-major, enable
105
+ 'react/hook-use-state': 'off',
106
+
107
+ // Enforce sandbox attribute on iframe elements
108
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/iframe-missing-sandbox.md
109
+ // TODO: semver-major, enable
110
+ 'react/iframe-missing-sandbox': 'error',
111
+
112
+ // Enforce boolean attributes notation in JSX
113
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
114
+ 'react/jsx-boolean-value': ['error', 'never'],
115
+
116
+ // Ensures inline tags are not rendered without spaces between them
117
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
118
+ // rule in stylistic.mjs
119
+ 'react/jsx-child-element-spacing': 'off',
120
+
121
+ // Validate closing bracket location in JSX
122
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
123
+ // rule in stylistic.mjs
124
+ 'react/jsx-closing-bracket-location': 'off',
125
+
126
+ // Validate closing tag location in JSX
127
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
128
+ // rule in stylistic.mjs
129
+ 'react/jsx-closing-tag-location': 'off',
130
+
131
+ // Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children
132
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
133
+ // rule in stylistic.mjs
134
+ 'react/jsx-curly-brace-presence': 'off',
135
+
136
+ // Enforce linebreaks in curly braces in JSX attributes and expressions.
137
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
138
+ // rule in stylistic.mjs
139
+ 'react/jsx-curly-newline': 'off',
140
+
141
+ // Enforce or disallow spaces inside of curly braces in JSX attributes
142
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
143
+ // rule in stylistic.mjs
144
+ 'react/jsx-curly-spacing': 'off',
145
+
146
+ // Enforce spacing around jsx equals signs
147
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
148
+ // rule in stylistic.mjs
149
+ 'react/jsx-equals-spacing': 'off',
150
+
151
+ // only .jsx files may have JSX
152
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
153
+ 'react/jsx-filename-extension': [
154
+ 'error',
155
+ {
156
+ extensions: ['.jsx'],
157
+ ignoreFilesWithoutCode: true,
158
+ },
159
+ ],
160
+
161
+ // Require that the first prop in a JSX element be on a new line when the element is multiline
162
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
163
+ // rule in stylistic.mjs
164
+ 'react/jsx-first-prop-new-line': 'off',
165
+
166
+ // Enforce shorthand or standard form for React fragments
167
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
168
+ 'react/jsx-fragments': ['error', 'syntax'],
169
+
170
+ // Enforce event handler naming conventions in JSX
171
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
172
+ 'react/jsx-handler-names': 'off',
173
+
174
+ // Enforce JSX indentation
175
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
176
+ 'react/jsx-indent': ['error', INDENT, { indentLogicalExpressions: true }],
177
+
178
+ // Validate props indentation in JSX
179
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
180
+ 'react/jsx-indent-props': ['error', { ignoreTernaryOperator: true, indentMode: INDENT }],
181
+
182
+ // Validate JSX has key prop when in array or iterator
183
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
184
+ // Turned off because it has too many false positives
185
+ 'react/jsx-key': [
186
+ 'error',
187
+ {
188
+ checkFragmentShorthand: true,
189
+ checkKeyMustBeforeSpread: true,
190
+ warnOnDuplicates: true,
191
+ },
192
+ ],
193
+
194
+ // Validate JSX maximum depth
195
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md
196
+ 'react/jsx-max-depth': ['error', { max: JSX_MAX_DEPTH }],
197
+
198
+ // Limit maximum of props on a single line in JSX
199
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
200
+ // rule in stylistic.mjs
201
+ 'react/jsx-max-props-per-line': 'off',
202
+
203
+ // Enforce a new line after jsx elements and expressions
204
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md
205
+ // rule in stylistic.mjs
206
+ 'react/jsx-newline': 'off',
207
+
208
+ // Prevent usage of .bind() in JSX props
209
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
210
+ 'react/jsx-no-bind': [
211
+ 'error',
212
+ {
213
+ allowArrowFunctions: true,
214
+ allowBind: false,
215
+ allowFunctions: false,
216
+ ignoreDOMComponents: false,
217
+ ignoreRefs: false,
218
+ },
219
+ ],
220
+
221
+ // prevent accidental JS comments from being injected into JSX as text
222
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
223
+ 'react/jsx-no-comment-textnodes': 'error',
224
+
225
+ // Prevent react contexts from taking non-stable values
226
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
227
+ 'react/jsx-no-constructed-context-values': 'error',
228
+
229
+ // Prevent duplicate props in JSX
230
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
231
+ 'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
232
+
233
+ // Prevent problematic leaked values from being rendered
234
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
235
+ // TODO: semver-major, enable
236
+ 'react/jsx-no-leaked-render': 'off',
237
+
238
+ // Prevent usage of unwrapped JSX strings
239
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
240
+ 'react/jsx-no-literals': 'off',
241
+
242
+ // Prevent usage of `javascript:` URLs
243
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
244
+ 'react/jsx-no-script-url': 'error',
245
+
246
+ // Disallow target="_blank" on links
247
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md
248
+ 'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
249
+
250
+ // Disallow undeclared variables in JSX
251
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
252
+ 'react/jsx-no-undef': ['error', { allowGlobals: false }],
253
+
254
+ // Disallow unnecessary fragments
255
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
256
+ 'react/jsx-no-useless-fragment': 'error',
257
+
258
+ // One JSX Element Per Line
259
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
260
+ // rule in stylistic.mjs
261
+ 'react/jsx-one-expression-per-line': 'off',
262
+
263
+ // Enforce PascalCase for user-defined JSX components
264
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
265
+ // rule in stylistic.mjs
266
+ 'react/jsx-pascal-case': 'off',
267
+
268
+ // Disallow multiple spaces between inline JSX props
269
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
270
+ // rule in stylistic.mjs
271
+ 'react/jsx-props-no-multi-spaces': 'error',
272
+
273
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
274
+ // TODO: semver-major, enable
275
+ 'react/jsx-props-no-spread-multi': 'error',
276
+
277
+ // Disallow JSX props spreading
278
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
279
+ 'react/jsx-props-no-spreading': 'off',
280
+
281
+ // Enforce props alphabetical sorting
282
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
283
+ // rule in stylistic.mjs
284
+ 'react/jsx-sort-props': 'off',
285
+
286
+ // Validate whitespace in and around the JSX opening and closing brackets
287
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
288
+ // rule in stylistic.mjs
289
+ 'react/jsx-tag-spacing': 'off',
290
+
291
+ // Prevent React to be incorrectly marked as unused
292
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
293
+ 'react/jsx-uses-react': 'error',
294
+
295
+ // Prevent variables used in JSX to be incorrectly marked as unused
296
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
297
+ 'react/jsx-uses-vars': 'error',
298
+
299
+ // Prevent missing parentheses around multilines JSX
300
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
301
+ // rule in stylistic.mjs
302
+ 'react/jsx-wrap-multilines': 'off',
303
+
304
+ // Prevent using this.state within a this.setState
305
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md
306
+ 'react/no-access-state-in-setstate': 'error',
307
+
308
+ // Prevent adjacent inline elements not separated by whitespace
309
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
310
+ // TODO: enable? semver-major
311
+ 'react/no-adjacent-inline-elements': 'off',
312
+
313
+ // Prevent usage of Array index in keys
314
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
315
+ 'react/no-array-index-key': 'error',
316
+
317
+ // Lifecycle methods should be methods on the prototype, not class fields
318
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-arrow-function-lifecycle.md
319
+ 'react/no-arrow-function-lifecycle': 'error',
320
+
321
+ // Prevent passing of children as props
322
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
323
+ 'react/no-children-prop': 'error',
324
+
325
+ // Prevent usage of dangerous JSX properties
326
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md
327
+ 'react/no-danger': 'warn',
328
+
329
+ // Prevent problem with children and props.dangerouslySetInnerHTML
330
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
331
+ 'react/no-danger-with-children': 'error',
332
+
333
+ // Prevent usage of deprecated methods
334
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
335
+ 'react/no-deprecated': 'error',
336
+
337
+ // Prevent usage of setState in componentDidMount
338
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
339
+ 'react/no-did-mount-set-state': 'error',
340
+
341
+ // Prevent usage of setState in componentDidUpdate
342
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
343
+ 'react/no-did-update-set-state': 'error',
344
+
345
+ // Prevent direct mutation of this.state
346
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
347
+ 'react/no-direct-mutation-state': 'error',
348
+
349
+ // warn against using findDOMNode()
350
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
351
+ 'react/no-find-dom-node': 'error',
352
+
353
+ // Prevent usage of invalid attributes
354
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-invalid-html-attribute.md
355
+ 'react/no-invalid-html-attribute': 'error',
356
+
357
+ // Prevent usage of isMounted
358
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
359
+ 'react/no-is-mounted': 'error',
360
+
361
+ // Prevent multiple component definition per file
362
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
363
+ 'react/no-multi-comp': ['error', { ignoreStateless: true }],
364
+
365
+ // Enforce that namespaces are not used in React elements
366
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-namespace.md
367
+ 'react/no-namespace': 'error',
368
+
369
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-object-type-as-default-prop.md
370
+ // TODO: semver-major, enable
371
+ 'react/no-object-type-as-default-prop': 'off',
372
+
373
+ // Prevent usage of shouldComponentUpdate when extending React.PureComponent
374
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md
375
+ 'react/no-redundant-should-component-update': 'error',
376
+
377
+ // disallow using React.render/ReactDOM.render's return value
378
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
379
+ 'react/no-render-return-value': 'error',
380
+
381
+ // Prevent usage of setState
382
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
383
+ 'react/no-set-state': 'off',
384
+
385
+ // Prevent using string references
386
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
387
+ 'react/no-string-refs': 'error',
388
+
389
+ // Prevent this from being used in stateless functional components
390
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
391
+ 'react/no-this-in-sfc': 'error',
392
+
393
+ // Prevents common casing typos
394
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-typos.md
395
+ 'react/no-typos': 'error',
396
+
397
+ // Prevent invalid characters from appearing in markup
398
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
399
+ 'react/no-unescaped-entities': 'error',
400
+
401
+ // Prevent usage of unknown DOM property
402
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
403
+ 'react/no-unknown-property': ['error', { requireDataLowercase: false }],
404
+
405
+ // Prevent usage of UNSAFE_ methods
406
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
407
+ 'react/no-unsafe': ['error', { checkAliases: true }],
408
+
409
+ // Prevent creating unstable components inside components
410
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
411
+ 'react/no-unstable-nested-components': 'error',
412
+
413
+ // Prevent declaring unused methods of component class
414
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md
415
+ 'react/no-unused-class-component-methods': 'error',
416
+
417
+ // Prevent unused propType definitions
418
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
419
+ 'react/no-unused-prop-types': ['error', { skipShapeProps: true }],
420
+
421
+ // Prevent unused state values
422
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
423
+ 'react/no-unused-state': 'error',
424
+
425
+ // Prevent usage of setState in componentWillUpdate
426
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
427
+ 'react/no-will-update-set-state': 'error',
428
+
429
+ // Require ES6 class declarations over React.createClass
430
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
431
+ 'react/prefer-es6-class': ['error', 'always'],
432
+
433
+ // Prefer exact proptype definitions
434
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md
435
+ 'react/prefer-exact-props': 'error',
436
+
437
+ // Enforce that props are read-only
438
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
439
+ 'react/prefer-read-only-props': 'error',
440
+
441
+ // Require stateless functions when not using lifecycle methods, setState or ref
442
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
443
+ 'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
444
+
445
+ // Prevent missing props validation in a React component definition
446
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md
447
+ 'react/prop-types': 'off',
448
+
449
+ // Prevent missing React when using JSX
450
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
451
+ 'react/react-in-jsx-scope': 'off',
452
+
453
+ // Enforce a defaultProps definition for every prop that is not a required prop
454
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
455
+ 'react/require-default-props': [
456
+ 'error',
457
+ {
458
+ forbidDefaultForRequired: true,
459
+ ignoreFunctionalComponents: true,
460
+ },
461
+ ],
462
+
463
+ // require a shouldComponentUpdate method, or PureRenderMixin
464
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
465
+ 'react/require-optimization': 'off',
466
+
467
+ // Require render() methods to return something
468
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
469
+ 'react/require-render-return': 'error',
470
+
471
+ // Prevent extra closing tags for components without children
472
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
473
+ 'react/self-closing-comp': [
474
+ 'error',
475
+ {
476
+ component: true,
477
+ html: true,
478
+ },
479
+ ],
480
+
481
+ // Enforce component methods order
482
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
483
+ 'react/sort-comp': [
484
+ 'error',
485
+ {
486
+ groups: {
487
+ lifecycle: [
488
+ 'displayName',
489
+ 'propTypes',
490
+ 'contextTypes',
491
+ 'childContextTypes',
492
+ 'mixins',
493
+ 'statics',
494
+ 'defaultProps',
495
+ 'constructor',
496
+ 'getDefaultProps',
497
+ 'getInitialState',
498
+ 'state',
499
+ 'getChildContext',
500
+ 'getDerivedStateFromProps',
501
+ 'componentWillMount',
502
+ 'UNSAFE_componentWillMount',
503
+ 'componentDidMount',
504
+ 'componentWillReceiveProps',
505
+ 'UNSAFE_componentWillReceiveProps',
506
+ 'shouldComponentUpdate',
507
+ 'componentWillUpdate',
508
+ 'UNSAFE_componentWillUpdate',
509
+ 'getSnapshotBeforeUpdate',
510
+ 'componentDidUpdate',
511
+ 'componentDidCatch',
512
+ 'componentWillUnmount',
513
+ ],
514
+ rendering: [
515
+ '/^render.+$/',
516
+ 'render',
517
+ ],
518
+ },
519
+ order: [
520
+ 'static-variables',
521
+ 'static-methods',
522
+ 'instance-variables',
523
+ 'lifecycle',
524
+ '/^handle.+$/',
525
+ '/^on.+$/',
526
+ 'getters',
527
+ 'setters',
528
+ '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
529
+ 'instance-methods',
530
+ 'everything-else',
531
+ 'rendering',
532
+ ],
533
+ },
534
+ ],
535
+
536
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-default-props.md
537
+ // TODO: semver-major, enable?
538
+ 'react/sort-default-props': ['off', { ignoreCase: true }],
539
+
540
+ // Enforce propTypes declarations alphabetical sorting
541
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
542
+ 'react/sort-prop-types': [
543
+ 'error',
544
+ {
545
+ callbacksLast: true,
546
+ checkTypes: false,
547
+ ignoreCase: false,
548
+ requiredFirst: false,
549
+ sortShapeProp: true,
550
+ },
551
+ ],
552
+
553
+ // Enforce state initialization style
554
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
555
+ // TODO: set to "never" once babel-preset-airbnb supports public class fields
556
+ 'react/state-in-constructor': ['error', 'always'],
557
+
558
+ // Enforces where React component static properties should be positioned
559
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
560
+ // TODO: set to "static public field" once babel-preset-airbnb supports public class fields
561
+ 'react/static-property-placement': ['error', 'static public field'],
562
+
563
+ // Require style prop value be an object or var
564
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
565
+ 'react/style-prop-object': 'error',
566
+
567
+ // Prevent void DOM elements from receiving children
568
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
569
+ 'react/void-dom-elements-no-children': 'error',
570
+ },
571
+ settings: {
572
+ componentWrapperFunctions: [
573
+ // The name of any function used to wrap components, e.g. Mobx `observer` function. If this isn't set, components wrapped by these functions will be skipped.
574
+ 'observer', // `property`
575
+ { property: 'styled' }, // `object` is optional
576
+ { object: 'Mobx', property: 'observer' },
577
+ { object: '<pragma>', property: 'observer' }, // sets `object` to whatever value `settings.react.pragma` is set to
578
+ ],
579
+ formComponents: [
580
+ // Components used as alternatives to <form> for forms, eg. <Form endpoint={ url } />
581
+ 'CustomForm',
582
+ { formAttribute: 'endpoint', name: 'SimpleForm' },
583
+ { formAttribute: ['registerEndpoint', 'loginEndpoint'], name: 'Form' }, // allows specifying multiple properties if necessary
584
+ ],
585
+ linkComponents: [
586
+ // Components used as alternatives to <a> for linking, eg. <Link to={ url } />
587
+ 'Hyperlink',
588
+ { linkAttribute: ['to', 'href'], name: 'Link' }, // allows specifying multiple properties if necessary
589
+ ],
590
+ propWrapperFunctions: [
591
+ // The names of any function used to wrap propTypes, e.g. `forbidExtraProps`. If this isn't set, any propTypes wrapped in a function will be skipped.
592
+ 'forbidExtraProps',
593
+ { object: 'Object', property: 'freeze' },
594
+ { property: 'myFavoriteWrapper' },
595
+ // for rules that check exact prop wrappers
596
+ { exact: true, property: 'forbidExtraProps' },
597
+ ],
598
+ react: {
599
+ createClass: 'createReactClass', // Regex for Component Factory to use,
600
+ defaultVersion: '', // Default React version to use when the version you have installed cannot be detected.
601
+ flowVersion: '0.53', // Flow version
602
+ fragment: 'Fragment', // Fragment to use (may be a property of <pragma>), default to "Fragment"
603
+ pragma: 'React', // Pragma to use, default to "React"
604
+ version: 'detect', // React version. "detect" automatically picks the version you have installed.
605
+ },
606
+ },
607
+ },
608
+ ];
609
+
610
+ export default config;
@@ -0,0 +1,10 @@
1
+ const config = [
2
+ {
3
+ name: 'react-refresh/refresh',
4
+ rules: {
5
+ 'react-refresh/only-export-components': 'error',
6
+ },
7
+ },
8
+ ];
9
+
10
+ export default config;