File tree Expand file tree Collapse file tree 14 files changed +52
-85
lines changed Expand file tree Collapse file tree 14 files changed +52
-85
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const has = require ( 'has' ) ;
8
7
const Components = require ( '../util/Components' ) ;
9
8
const propsUtil = require ( '../util/props' ) ;
10
9
const docsUrl = require ( '../util/docsUrl' ) ;
@@ -248,7 +247,7 @@ module.exports = {
248
247
}
249
248
}
250
249
251
- if ( ! has ( list , component ) || ( list [ component ] . invalidProps || [ ] ) . length ) {
250
+ if ( ( list [ component ] . invalidProps || [ ] ) . length ) {
252
251
reportInvalidNaming ( list [ component ] ) ;
253
252
}
254
253
} ) ;
Original file line number Diff line number Diff line change 5
5
*/
6
6
'use strict' ;
7
7
8
- const has = require ( 'has' ) ;
9
8
const Components = require ( '../util/Components' ) ;
10
9
const variableUtil = require ( '../util/variable' ) ;
11
10
const annotations = require ( '../util/annotations' ) ;
@@ -595,11 +594,7 @@ module.exports = {
595
594
stack = null ;
596
595
const list = components . list ( ) ;
597
596
598
- for ( const component in list ) {
599
- if ( ! has ( list , component ) ) {
600
- continue ;
601
- }
602
-
597
+ Object . keys ( list ) . forEach ( component => {
603
598
// If no defaultProps could be found, we don't report anything.
604
599
if ( ! list [ component ] . defaultProps ) {
605
600
return ;
@@ -609,7 +604,7 @@ module.exports = {
609
604
list [ component ] . propTypes ,
610
605
list [ component ] . defaultProps || { }
611
606
) ;
612
- }
607
+ } ) ;
613
608
}
614
609
} ;
615
610
} )
Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const has = require ( 'has' ) ;
8
7
const Components = require ( '../util/Components' ) ;
9
8
const astUtil = require ( '../util/ast' ) ;
10
9
const docsUrl = require ( '../util/docsUrl' ) ;
@@ -216,12 +215,12 @@ module.exports = {
216
215
'Program:exit' : function ( ) {
217
216
const list = components . list ( ) ;
218
217
// Report missing display name for all components
219
- for ( const component in list ) {
220
- if ( ! has ( list , component ) || list [ component ] . hasDisplayName ) {
221
- continue ;
218
+ Object . keys ( list ) . forEach ( component => {
219
+ if ( list [ component ] . hasDisplayName ) {
220
+ return ;
222
221
}
223
222
reportMissingDisplayName ( list [ component ] ) ;
224
- }
223
+ } ) ;
225
224
}
226
225
} ;
227
226
} )
Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const has = require ( 'has' ) ;
8
7
const Components = require ( '../util/Components' ) ;
9
8
const docsUrl = require ( '../util/docsUrl' ) ;
10
9
@@ -61,15 +60,15 @@ module.exports = {
61
60
const list = components . list ( ) ;
62
61
let i = 0 ;
63
62
64
- for ( const component in list ) {
65
- if ( ! has ( list , component ) || isIgnored ( list [ component ] ) || ++ i === 1 ) {
66
- continue ;
63
+ Object . keys ( list ) . forEach ( component => {
64
+ if ( isIgnored ( list [ component ] ) || ++ i === 1 ) {
65
+ return ;
67
66
}
68
67
context . report ( {
69
68
node : list [ component ] . node ,
70
69
message : MULTI_COMP_MESSAGE
71
70
} ) ;
72
- }
71
+ } ) ;
73
72
}
74
73
} ;
75
74
} )
Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const has = require ( 'has' ) ;
8
7
const Components = require ( '../util/Components' ) ;
9
8
const docsUrl = require ( '../util/docsUrl' ) ;
10
9
@@ -74,12 +73,12 @@ module.exports = {
74
73
75
74
'Program:exit' : function ( ) {
76
75
const list = components . list ( ) ;
77
- for ( const component in list ) {
78
- if ( ! has ( list , component ) || isValid ( list [ component ] ) ) {
79
- continue ;
76
+ Object . keys ( list ) . forEach ( component => {
77
+ if ( isValid ( list [ component ] ) ) {
78
+ return ;
80
79
}
81
80
reportSetStateUsages ( list [ component ] ) ;
82
- }
81
+ } ) ;
83
82
}
84
83
} ;
85
84
} )
Original file line number Diff line number Diff line change 7
7
// As for exceptions for props.children or props.className (and alike) look at
8
8
// https://github.com/yannickcr/eslint-plugin-react/issues/7
9
9
10
- const has = require ( 'has' ) ;
11
10
const Components = require ( '../util/Components' ) ;
12
11
const docsUrl = require ( '../util/docsUrl' ) ;
13
12
@@ -133,12 +132,12 @@ module.exports = {
133
132
'Program:exit' : function ( ) {
134
133
const list = components . list ( ) ;
135
134
// Report undeclared proptypes for all classes
136
- for ( const component in list ) {
137
- if ( ! has ( list , component ) || ! mustBeValidated ( list [ component ] ) ) {
138
- continue ;
135
+ Object . keys ( list ) . forEach ( component => {
136
+ if ( ! mustBeValidated ( list [ component ] ) ) {
137
+ return ;
139
138
}
140
139
reportUnusedPropTypes ( list [ component ] ) ;
141
- }
140
+ } ) ;
142
141
}
143
142
} ;
144
143
} )
Original file line number Diff line number Diff line change 6
6
*/
7
7
'use strict' ;
8
8
9
- const has = require ( 'has' ) ;
10
9
const Components = require ( '../util/Components' ) ;
11
10
const versionUtil = require ( '../util/version' ) ;
12
11
const astUtil = require ( '../util/ast' ) ;
@@ -357,9 +356,8 @@ module.exports = {
357
356
358
357
'Program:exit' : function ( ) {
359
358
const list = components . list ( ) ;
360
- for ( const component in list ) {
359
+ Object . keys ( list ) . forEach ( component => {
361
360
if (
362
- ! has ( list , component ) ||
363
361
hasOtherProperties ( list [ component ] . node ) ||
364
362
list [ component ] . useThis ||
365
363
list [ component ] . useRef ||
@@ -368,17 +366,17 @@ module.exports = {
368
366
list [ component ] . useDecorators ||
369
367
( ! utils . isES5Component ( list [ component ] . node ) && ! utils . isES6Component ( list [ component ] . node ) )
370
368
) {
371
- continue ;
369
+ return ;
372
370
}
373
371
374
372
if ( list [ component ] . hasSCU && list [ component ] . usePropsOrContext ) {
375
- continue ;
373
+ return ;
376
374
}
377
375
context . report ( {
378
376
node : list [ component ] . node ,
379
377
message : 'Component should be written as a pure function'
380
378
} ) ;
381
- }
379
+ } ) ;
382
380
}
383
381
} ;
384
382
} )
Original file line number Diff line number Diff line change 7
7
// As for exceptions for props.children or props.className (and alike) look at
8
8
// https://github.com/yannickcr/eslint-plugin-react/issues/7
9
9
10
- const has = require ( 'has' ) ;
11
10
const Components = require ( '../util/Components' ) ;
12
11
const docsUrl = require ( '../util/docsUrl' ) ;
13
12
@@ -190,12 +189,12 @@ module.exports = {
190
189
'Program:exit' : function ( ) {
191
190
const list = components . list ( ) ;
192
191
// Report undeclared proptypes for all classes
193
- for ( const component in list ) {
194
- if ( ! has ( list , component ) || ! mustBeValidated ( list [ component ] ) ) {
195
- continue ;
192
+ Object . keys ( list ) . forEach ( component => {
193
+ if ( ! mustBeValidated ( list [ component ] ) ) {
194
+ return ;
196
195
}
197
196
reportUndeclaredPropTypes ( list [ component ] ) ;
198
- }
197
+ } ) ;
199
198
}
200
199
} ;
201
200
} )
Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const has = require ( 'has' ) ;
8
7
const Components = require ( '../util/Components' ) ;
9
8
const variableUtil = require ( '../util/variable' ) ;
10
9
const annotations = require ( '../util/annotations' ) ;
@@ -626,21 +625,17 @@ module.exports = {
626
625
stack = null ;
627
626
const list = components . list ( ) ;
628
627
629
- for ( const component in list ) {
630
- if ( ! has ( list , component ) ) {
631
- continue ;
632
- }
633
-
628
+ Object . keys ( list ) . forEach ( component => {
634
629
// If no propTypes could be found, we don't report anything.
635
630
if ( ! list [ component ] . propTypes ) {
636
- continue ;
631
+ return ;
637
632
}
638
633
639
634
reportPropTypesWithoutDefault (
640
635
list [ component ] . propTypes ,
641
636
list [ component ] . defaultProps || { }
642
637
) ;
643
- }
638
+ } ) ;
644
639
}
645
640
} ;
646
641
} )
Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const has = require ( 'has' ) ;
8
7
const Components = require ( '../util/Components' ) ;
9
8
const docsUrl = require ( '../util/docsUrl' ) ;
10
9
@@ -221,12 +220,12 @@ module.exports = {
221
220
const list = components . list ( ) ;
222
221
223
222
// Report missing shouldComponentUpdate for all components
224
- for ( const component in list ) {
225
- if ( ! has ( list , component ) || list [ component ] . hasSCU ) {
226
- continue ;
223
+ Object . keys ( list ) . forEach ( component => {
224
+ if ( list [ component ] . hasSCU ) {
225
+ return ;
227
226
}
228
227
reportMissingOptimization ( list [ component ] ) ;
229
- }
228
+ } ) ;
230
229
}
231
230
} ;
232
231
} )
You can’t perform that action at this time.
0 commit comments