@@ -36,12 +36,9 @@ function usedPropTypesAreEquivalent(propA, propB) {
36
36
}
37
37
38
38
function mergeUsedPropTypes ( propsList , newPropsList ) {
39
- const propsToAdd = [ ] ;
40
- newPropsList . forEach ( ( newProp ) => {
41
- const newPropisAlreadyInTheList = propsList . some ( ( prop ) => usedPropTypesAreEquivalent ( prop , newProp ) ) ;
42
- if ( ! newPropisAlreadyInTheList ) {
43
- propsToAdd . push ( newProp ) ;
44
- }
39
+ const propsToAdd = newPropsList . filter ( ( newProp ) => {
40
+ const newPropIsAlreadyInTheList = propsList . some ( ( prop ) => usedPropTypesAreEquivalent ( prop , newProp ) ) ;
41
+ return ! newPropIsAlreadyInTheList ;
45
42
} ) ;
46
43
47
44
return propsList . concat ( propsToAdd ) ;
@@ -412,30 +409,6 @@ function componentRule(rule, context) {
412
409
return node . type === 'MemberExpression' && node . object . type === 'ThisExpression' && node . property . name === 'state' ;
413
410
} ,
414
411
415
- getReturnPropertyAndNode ( ASTnode ) {
416
- let property ;
417
- let node = ASTnode ;
418
- switch ( node . type ) {
419
- case 'ReturnStatement' :
420
- property = 'argument' ;
421
- break ;
422
- case 'ArrowFunctionExpression' :
423
- property = 'body' ;
424
- if ( node [ property ] && node [ property ] . type === 'BlockStatement' ) {
425
- node = utils . findReturnStatement ( node ) ;
426
- property = 'argument' ;
427
- }
428
- break ;
429
- default :
430
- node = utils . findReturnStatement ( node ) ;
431
- property = 'argument' ;
432
- }
433
- return {
434
- node,
435
- property
436
- } ;
437
- } ,
438
-
439
412
isReturningJSX ( ASTNode , strict ) {
440
413
return jsxUtil . isReturningJSX ( this . isCreateElement . bind ( this ) , ASTNode , strict , true ) ;
441
414
} ,
@@ -552,9 +525,9 @@ function componentRule(rule, context) {
552
525
} ,
553
526
554
527
/**
555
- * Find a return statment in the current node
528
+ * Find a return statement in the current node
556
529
*
557
- * @param {ASTNode } ASTnode The AST node being checked
530
+ * @param {ASTNode } node The AST node being checked
558
531
*/
559
532
findReturnStatement : astUtil . findReturnStatement ,
560
533
0 commit comments