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 44 */
55'use strict' ;
66
7- const has = require ( 'has' ) ;
87const Components = require ( '../util/Components' ) ;
98const propsUtil = require ( '../util/props' ) ;
109const docsUrl = require ( '../util/docsUrl' ) ;
@@ -248,7 +247,7 @@ module.exports = {
248247 }
249248 }
250249
251- if ( ! has ( list , component ) || ( list [ component ] . invalidProps || [ ] ) . length ) {
250+ if ( ( list [ component ] . invalidProps || [ ] ) . length ) {
252251 reportInvalidNaming ( list [ component ] ) ;
253252 }
254253 } ) ;
Original file line number Diff line number Diff line change 55 */
66'use strict' ;
77
8- const has = require ( 'has' ) ;
98const Components = require ( '../util/Components' ) ;
109const variableUtil = require ( '../util/variable' ) ;
1110const annotations = require ( '../util/annotations' ) ;
@@ -595,11 +594,7 @@ module.exports = {
595594 stack = null ;
596595 const list = components . list ( ) ;
597596
598- for ( const component in list ) {
599- if ( ! has ( list , component ) ) {
600- continue ;
601- }
602-
597+ Object . keys ( list ) . forEach ( component => {
603598 // If no defaultProps could be found, we don't report anything.
604599 if ( ! list [ component ] . defaultProps ) {
605600 return ;
@@ -609,7 +604,7 @@ module.exports = {
609604 list [ component ] . propTypes ,
610605 list [ component ] . defaultProps || { }
611606 ) ;
612- }
607+ } ) ;
613608 }
614609 } ;
615610 } )
Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const has = require ( 'has' ) ;
87const Components = require ( '../util/Components' ) ;
98const astUtil = require ( '../util/ast' ) ;
109const docsUrl = require ( '../util/docsUrl' ) ;
@@ -216,12 +215,12 @@ module.exports = {
216215 'Program:exit' : function ( ) {
217216 const list = components . list ( ) ;
218217 // 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 ;
222221 }
223222 reportMissingDisplayName ( list [ component ] ) ;
224- }
223+ } ) ;
225224 }
226225 } ;
227226 } )
Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const has = require ( 'has' ) ;
87const Components = require ( '../util/Components' ) ;
98const docsUrl = require ( '../util/docsUrl' ) ;
109
@@ -61,15 +60,15 @@ module.exports = {
6160 const list = components . list ( ) ;
6261 let i = 0 ;
6362
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 ;
6766 }
6867 context . report ( {
6968 node : list [ component ] . node ,
7069 message : MULTI_COMP_MESSAGE
7170 } ) ;
72- }
71+ } ) ;
7372 }
7473 } ;
7574 } )
Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const has = require ( 'has' ) ;
87const Components = require ( '../util/Components' ) ;
98const docsUrl = require ( '../util/docsUrl' ) ;
109
@@ -74,12 +73,12 @@ module.exports = {
7473
7574 'Program:exit' : function ( ) {
7675 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 ;
8079 }
8180 reportSetStateUsages ( list [ component ] ) ;
82- }
81+ } ) ;
8382 }
8483 } ;
8584 } )
Original file line number Diff line number Diff line change 77// As for exceptions for props.children or props.className (and alike) look at
88// https://github.com/yannickcr/eslint-plugin-react/issues/7
99
10- const has = require ( 'has' ) ;
1110const Components = require ( '../util/Components' ) ;
1211const docsUrl = require ( '../util/docsUrl' ) ;
1312
@@ -133,12 +132,12 @@ module.exports = {
133132 'Program:exit' : function ( ) {
134133 const list = components . list ( ) ;
135134 // 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 ;
139138 }
140139 reportUnusedPropTypes ( list [ component ] ) ;
141- }
140+ } ) ;
142141 }
143142 } ;
144143 } )
Original file line number Diff line number Diff line change 66 */
77'use strict' ;
88
9- const has = require ( 'has' ) ;
109const Components = require ( '../util/Components' ) ;
1110const versionUtil = require ( '../util/version' ) ;
1211const astUtil = require ( '../util/ast' ) ;
@@ -357,9 +356,8 @@ module.exports = {
357356
358357 'Program:exit' : function ( ) {
359358 const list = components . list ( ) ;
360- for ( const component in list ) {
359+ Object . keys ( list ) . forEach ( component => {
361360 if (
362- ! has ( list , component ) ||
363361 hasOtherProperties ( list [ component ] . node ) ||
364362 list [ component ] . useThis ||
365363 list [ component ] . useRef ||
@@ -368,17 +366,17 @@ module.exports = {
368366 list [ component ] . useDecorators ||
369367 ( ! utils . isES5Component ( list [ component ] . node ) && ! utils . isES6Component ( list [ component ] . node ) )
370368 ) {
371- continue ;
369+ return ;
372370 }
373371
374372 if ( list [ component ] . hasSCU && list [ component ] . usePropsOrContext ) {
375- continue ;
373+ return ;
376374 }
377375 context . report ( {
378376 node : list [ component ] . node ,
379377 message : 'Component should be written as a pure function'
380378 } ) ;
381- }
379+ } ) ;
382380 }
383381 } ;
384382 } )
Original file line number Diff line number Diff line change 77// As for exceptions for props.children or props.className (and alike) look at
88// https://github.com/yannickcr/eslint-plugin-react/issues/7
99
10- const has = require ( 'has' ) ;
1110const Components = require ( '../util/Components' ) ;
1211const docsUrl = require ( '../util/docsUrl' ) ;
1312
@@ -190,12 +189,12 @@ module.exports = {
190189 'Program:exit' : function ( ) {
191190 const list = components . list ( ) ;
192191 // 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 ;
196195 }
197196 reportUndeclaredPropTypes ( list [ component ] ) ;
198- }
197+ } ) ;
199198 }
200199 } ;
201200 } )
Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const has = require ( 'has' ) ;
87const Components = require ( '../util/Components' ) ;
98const variableUtil = require ( '../util/variable' ) ;
109const annotations = require ( '../util/annotations' ) ;
@@ -626,21 +625,17 @@ module.exports = {
626625 stack = null ;
627626 const list = components . list ( ) ;
628627
629- for ( const component in list ) {
630- if ( ! has ( list , component ) ) {
631- continue ;
632- }
633-
628+ Object . keys ( list ) . forEach ( component => {
634629 // If no propTypes could be found, we don't report anything.
635630 if ( ! list [ component ] . propTypes ) {
636- continue ;
631+ return ;
637632 }
638633
639634 reportPropTypesWithoutDefault (
640635 list [ component ] . propTypes ,
641636 list [ component ] . defaultProps || { }
642637 ) ;
643- }
638+ } ) ;
644639 }
645640 } ;
646641 } )
Original file line number Diff line number Diff line change 44 */
55'use strict' ;
66
7- const has = require ( 'has' ) ;
87const Components = require ( '../util/Components' ) ;
98const docsUrl = require ( '../util/docsUrl' ) ;
109
@@ -221,12 +220,12 @@ module.exports = {
221220 const list = components . list ( ) ;
222221
223222 // 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 ;
227226 }
228227 reportMissingOptimization ( list [ component ] ) ;
229- }
228+ } ) ;
230229 }
231230 } ;
232231 } )
You can’t perform that action at this time.
0 commit comments