@@ -483,14 +483,16 @@ function componentRule(rule, context) {
483
483
} ,
484
484
485
485
FunctionExpression : function ( node ) {
486
- node = utils . getParentComponent ( ) ;
486
+ var component = utils . getParentComponent ( ) ;
487
487
if (
488
- ! node ||
489
- ( node . parent && node . parent . type === 'JSXExpressionContainer' )
488
+ ! component ||
489
+ ( component . parent && component . parent . type === 'JSXExpressionContainer' )
490
490
) {
491
+ // Ban the node if we cannot find a parent component
492
+ components . add ( node , 0 ) ;
491
493
return ;
492
494
}
493
- components . add ( node , 1 ) ;
495
+ components . add ( component , 1 ) ;
494
496
} ,
495
497
496
498
FunctionDeclaration : function ( node ) {
@@ -502,17 +504,19 @@ function componentRule(rule, context) {
502
504
} ,
503
505
504
506
ArrowFunctionExpression : function ( node ) {
505
- node = utils . getParentComponent ( ) ;
507
+ var component = utils . getParentComponent ( ) ;
506
508
if (
507
- ! node ||
508
- ( node . parent && node . parent . type === 'JSXExpressionContainer' )
509
+ ! component ||
510
+ ( component . parent && component . parent . type === 'JSXExpressionContainer' )
509
511
) {
512
+ // Ban the node if we cannot find a parent component
513
+ components . add ( node , 0 ) ;
510
514
return ;
511
515
}
512
- if ( node . expression && utils . isReturningJSX ( node ) ) {
513
- components . add ( node , 2 ) ;
516
+ if ( component . expression && utils . isReturningJSX ( component ) ) {
517
+ components . add ( component , 2 ) ;
514
518
} else {
515
- components . add ( node , 1 ) ;
519
+ components . add ( component , 1 ) ;
516
520
}
517
521
} ,
518
522
0 commit comments