@@ -38,8 +38,16 @@ module.exports = {
38
38
'react/display-name' : [ 'off' , { ignoreTranspilerName : false } ] ,
39
39
40
40
// Forbid certain propTypes (any, array, object)
41
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
42
- 'react/forbid-prop-types' : [ 'error' , { forbid : [ 'any' , 'array' , 'object' ] } ] ,
41
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md
42
+ 'react/forbid-prop-types' : [ 'error' , {
43
+ forbid : [ 'any' , 'array' , 'object' ] ,
44
+ checkContextTypes : true ,
45
+ checkChildContextTypes : true ,
46
+ } ] ,
47
+
48
+ // Forbid certain props on DOM Nodes
49
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md
50
+ 'react/forbid-dom-props' : [ 'off' , { forbid : [ ] } ] ,
43
51
44
52
// Enforce boolean attributes notation in JSX
45
53
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
@@ -109,6 +117,7 @@ module.exports = {
109
117
ignoreCase : true ,
110
118
callbacksLast : false ,
111
119
requiredFirst : false ,
120
+ sortShapeProp : true ,
112
121
} ] ,
113
122
114
123
// Deprecated in favor of react/jsx-sort-props
@@ -125,6 +134,12 @@ module.exports = {
125
134
reservedFirst : true ,
126
135
} ] ,
127
136
137
+ // Enforce defaultProps declarations alphabetical sorting
138
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md
139
+ 'react/jsx-sort-default-props' : [ 'off' , {
140
+ ignoreCase : true ,
141
+ } ] ,
142
+
128
143
// Prevent React to be incorrectly marked as unused
129
144
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
130
145
'react/jsx-uses-react' : [ 'error' ] ,
@@ -207,28 +222,59 @@ module.exports = {
207
222
'react/self-closing-comp' : 'error' ,
208
223
209
224
// Enforce component methods order
210
- // https://github.com/yannickcr/eslint-plugin-react/blob/master /docs/rules/sort-comp.md
225
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b /docs/rules/sort-comp.md
211
226
'react/sort-comp' : [ 'error' , {
212
227
order : [
213
228
'static-methods' ,
229
+ 'instance-variables' ,
214
230
'lifecycle' ,
215
231
'/^on.+$/' ,
216
232
'getters' ,
217
233
'setters' ,
218
234
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/' ,
235
+ 'instance-methods' ,
219
236
'everything-else' ,
220
- '/^render.+$/' ,
221
- 'render'
237
+ 'rendering' ,
222
238
] ,
239
+ groups : {
240
+ lifecycle : [
241
+ 'displayName' ,
242
+ 'propTypes' ,
243
+ 'contextTypes' ,
244
+ 'childContextTypes' ,
245
+ 'mixins' ,
246
+ 'statics' ,
247
+ 'defaultProps' ,
248
+ 'constructor' ,
249
+ 'getDefaultProps' ,
250
+ 'getInitialState' ,
251
+ 'state' ,
252
+ 'getChildContext' ,
253
+ 'componentWillMount' ,
254
+ 'componentDidMount' ,
255
+ 'componentWillReceiveProps' ,
256
+ 'shouldComponentUpdate' ,
257
+ 'componentWillUpdate' ,
258
+ 'componentDidUpdate' ,
259
+ 'componentWillUnmount' ,
260
+ ] ,
261
+ rendering : [
262
+ '/^render.+$/' ,
263
+ 'render'
264
+ ] ,
265
+ } ,
223
266
} ] ,
224
267
225
268
// Prevent missing parentheses around multilines JSX
226
- // https://github.com/yannickcr/eslint-plugin-react/blob/master /docs/rules/jsx-wrap-multilines.md
269
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b /docs/rules/jsx-wrap-multilines.md
227
270
'react/jsx-wrap-multilines' : [ 'error' , {
228
- declaration : true ,
229
- assignment : true ,
230
- return : true ,
231
- arrow : true ,
271
+ declaration : 'parens-new-line' ,
272
+ assignment : 'parens-new-line' ,
273
+ return : 'parens-new-line' ,
274
+ arrow : 'parens-new-line' ,
275
+ condition : 'parens-new-line' ,
276
+ logical : 'parens-new-line' ,
277
+ prop : 'parens-new-line' ,
232
278
} ] ,
233
279
234
280
// Require that the first prop in a JSX element be on a new line when the element is multiline
@@ -300,11 +346,12 @@ module.exports = {
300
346
'react/no-children-prop' : 'error' ,
301
347
302
348
// Validate whitespace in and around the JSX opening and closing brackets
303
- // https://github.com/yannickcr/eslint-plugin-react/blob/master /docs/rules/jsx-tag-spacing.md
349
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b /docs/rules/jsx-tag-spacing.md
304
350
'react/jsx-tag-spacing' : [ 'error' , {
305
351
closingSlash : 'never' ,
306
352
beforeSelfClosing : 'always' ,
307
- afterOpening : 'never'
353
+ afterOpening : 'never' ,
354
+ beforeClosing : 'never' ,
308
355
} ] ,
309
356
310
357
// Enforce spaces before the closing bracket of self-closing JSX elements
@@ -317,8 +364,10 @@ module.exports = {
317
364
'react/no-array-index-key' : 'error' ,
318
365
319
366
// Enforce a defaultProps definition for every prop that is not a required prop
320
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
321
- 'react/require-default-props' : 'error' ,
367
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md
368
+ 'react/require-default-props' : [ 'error' , {
369
+ forbidDefaultForRequired : true ,
370
+ } ] ,
322
371
323
372
// Forbids using non-exported propTypes
324
373
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
@@ -341,10 +390,11 @@ module.exports = {
341
390
'react/no-unused-state' : 'error' ,
342
391
343
392
// Enforces consistent naming for boolean props
344
- // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91 /docs/rules/boolean-prop-naming.md
393
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b /docs/rules/boolean-prop-naming.md
345
394
'react/boolean-prop-naming' : [ 'off' , {
346
395
propTypeNames : [ 'bool' , 'mutuallyExclusiveTrueProps' ] ,
347
396
rule : '^(is|has)[A-Z]([A-Za-z0-9]?)+' ,
397
+ message : '' ,
348
398
} ] ,
349
399
350
400
// Prevents common casing typos
@@ -353,7 +403,34 @@ module.exports = {
353
403
354
404
// Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children
355
405
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
356
- 'react/jsx-curly-brace-presence' : [ 'error' , { props : 'never' , children : 'never' } ]
406
+ 'react/jsx-curly-brace-presence' : [ 'error' , { props : 'never' , children : 'never' } ] ,
407
+
408
+ // One JSX Element Per Line
409
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md
410
+ 'react/jsx-one-expression-per-line' : 'error' ,
411
+
412
+ // Enforce consistent usage of destructuring assignment of props, state, and context
413
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md
414
+ 'react/destructuring-assignment' : [ 'error' , 'always' ] ,
415
+
416
+ // Prevent using this.state within a this.setState
417
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md
418
+ 'react/no-access-state-in-setstate' : 'error' ,
419
+
420
+ // Prevent usage of button elements without an explicit type attribute
421
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md
422
+ 'react/button-has-type' : [ 'error' , {
423
+ button : true ,
424
+ submit : true ,
425
+ reset : false ,
426
+ } ] ,
427
+
428
+ // Ensures inline tags are not rendered without spaces between them
429
+ 'react/jsx-child-element-spacing' : 'off' ,
430
+
431
+ // Prevent this from being used in stateless functional components
432
+ // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md
433
+ 'react/no-this-in-sfc' : 'error' ,
357
434
} ,
358
435
359
436
settings : {
0 commit comments