@@ -483,14 +483,16 @@ function componentRule(rule, context) {
483483 } ,
484484
485485 FunctionExpression : function ( node ) {
486- node = utils . getParentComponent ( ) ;
486+ var component = utils . getParentComponent ( ) ;
487487 if (
488- ! node ||
489- ( node . parent && node . parent . type === 'JSXExpressionContainer' )
488+ ! component ||
489+ ( component . parent && component . parent . type === 'JSXExpressionContainer' )
490490 ) {
491+ // Ban the node if we cannot find a parent component
492+ components . add ( node , 0 ) ;
491493 return ;
492494 }
493- components . add ( node , 1 ) ;
495+ components . add ( component , 1 ) ;
494496 } ,
495497
496498 FunctionDeclaration : function ( node ) {
@@ -502,17 +504,19 @@ function componentRule(rule, context) {
502504 } ,
503505
504506 ArrowFunctionExpression : function ( node ) {
505- node = utils . getParentComponent ( ) ;
507+ var component = utils . getParentComponent ( ) ;
506508 if (
507- ! node ||
508- ( node . parent && node . parent . type === 'JSXExpressionContainer' )
509+ ! component ||
510+ ( component . parent && component . parent . type === 'JSXExpressionContainer' )
509511 ) {
512+ // Ban the node if we cannot find a parent component
513+ components . add ( node , 0 ) ;
510514 return ;
511515 }
512- if ( node . expression && utils . isReturningJSX ( node ) ) {
513- components . add ( node , 2 ) ;
516+ if ( component . expression && utils . isReturningJSX ( component ) ) {
517+ components . add ( component , 2 ) ;
514518 } else {
515- components . add ( node , 1 ) ;
519+ components . add ( component , 1 ) ;
516520 }
517521 } ,
518522
0 commit comments