@@ -99,7 +99,7 @@ Components.prototype.length = function () {
9999  return  length ; 
100100} ; 
101101
102- function  componentRule ( rule ,  context )  { 
102+ function  componentRule ( rule ,  context ,   _node )  { 
103103  const  sourceCode  =  context . getSourceCode ( ) ; 
104104  const  components  =  new  Components ( ) ; 
105105
@@ -165,11 +165,11 @@ function componentRule(rule, context) {
165165     * 
166166     * @returns  {ASTNode } component node, null if we are not in a component 
167167     */ 
168-     getParentComponent : function  ( )  { 
168+     getParentComponent : function  ( _n )  { 
169169      return  ( 
170-         utils . getParentES6Component ( ) 
171-         ||  utils . getParentES5Component ( ) 
172-         ||  utils . getParentStatelessComponent ( ) 
170+         utils . getParentES6Component ( _n ) 
171+         ||  utils . getParentES5Component ( _n ) 
172+         ||  utils . getParentStatelessComponent ( _n ) 
173173      ) ; 
174174    } , 
175175
@@ -178,9 +178,9 @@ function componentRule(rule, context) {
178178     * 
179179     * @returns  {ASTNode } component node, null if we are not in a component 
180180     */ 
181-     getParentES5Component : function  ( )  { 
181+     getParentES5Component : function  ( _n )  { 
182182      // eslint-disable-next-line react/destructuring-assignment 
183-       let  scope  =  context . getScope ( ) ; 
183+       let  scope  =  ( context . sourceCode   ||   context ) . getScope ( _n ) ; 
184184      while  ( scope )  { 
185185        const  node  =  scope . block  &&  scope . block . parent  &&  scope . block . parent . parent ; 
186186        if  ( node  &&  utils . isES5Component ( node ) )  { 
@@ -196,8 +196,8 @@ function componentRule(rule, context) {
196196     * 
197197     * @returns  {ASTNode } component node, null if we are not in a component 
198198     */ 
199-     getParentES6Component : function  ( )  { 
200-       let  scope  =  context . getScope ( ) ; 
199+     getParentES6Component : function  ( _n )  { 
200+       let  scope  =  ( context . sourceCode   ||   context ) . getScope ( _n ) ; 
201201      while  ( scope  &&  scope . type  !==  'class' )  { 
202202        scope  =  scope . upper ; 
203203      } 
@@ -213,9 +213,9 @@ function componentRule(rule, context) {
213213     * 
214214     * @returns  {ASTNode } component node, null if we are not in a component 
215215     */ 
216-     getParentStatelessComponent : function  ( )  { 
216+     getParentStatelessComponent : function  ( _n )  { 
217217      // eslint-disable-next-line react/destructuring-assignment 
218-       let  scope  =  context . getScope ( ) ; 
218+       let  scope  =  ( context . sourceCode   ||   context ) . getScope ( _n ) ; 
219219      while  ( scope )  { 
220220        const  node  =  scope . block ; 
221221        // Ignore non functions 
@@ -263,7 +263,7 @@ function componentRule(rule, context) {
263263        return  null ; 
264264      } 
265265      let  variableInScope ; 
266-       const  {  variables }  =  context . getScope ( ) ; 
266+       const  {  variables }  =  ( context . sourceCode   ||   context ) . getScope ( _node ) ; 
267267      for  ( i  =  0 ,  j  =  variables . length ;  i  <  j ;  i ++ )  {  // eslint-disable-line no-plusplus 
268268        if  ( variables [ i ] . name  ===  variableName )  { 
269269          variableInScope  =  variables [ i ] ; 
@@ -323,8 +323,8 @@ function componentRule(rule, context) {
323323      components . add ( node ,  2 ) ; 
324324    } , 
325325
326-     ClassProperty : function  ( )  { 
327-       const  node  =  utils . getParentComponent ( ) ; 
326+     ClassProperty : function  ( _n )  { 
327+       const  node  =  utils . getParentComponent ( _n ) ; 
328328      if  ( ! node )  { 
329329        return ; 
330330      } 
@@ -338,24 +338,24 @@ function componentRule(rule, context) {
338338      components . add ( node ,  2 ) ; 
339339    } , 
340340
341-     FunctionExpression : function  ( )  { 
342-       const  node  =  utils . getParentComponent ( ) ; 
341+     FunctionExpression : function  ( _n )  { 
342+       const  node  =  utils . getParentComponent ( _n ) ; 
343343      if  ( ! node )  { 
344344        return ; 
345345      } 
346346      components . add ( node ,  1 ) ; 
347347    } , 
348348
349-     FunctionDeclaration : function  ( )  { 
350-       const  node  =  utils . getParentComponent ( ) ; 
349+     FunctionDeclaration : function  ( _n )  { 
350+       const  node  =  utils . getParentComponent ( _n ) ; 
351351      if  ( ! node )  { 
352352        return ; 
353353      } 
354354      components . add ( node ,  1 ) ; 
355355    } , 
356356
357-     ArrowFunctionExpression : function  ( )  { 
358-       const  node  =  utils . getParentComponent ( ) ; 
357+     ArrowFunctionExpression : function  ( _n )  { 
358+       const  node  =  utils . getParentComponent ( _n ) ; 
359359      if  ( ! node )  { 
360360        return ; 
361361      } 
@@ -366,8 +366,8 @@ function componentRule(rule, context) {
366366      } 
367367    } , 
368368
369-     ThisExpression : function  ( )  { 
370-       const  node  =  utils . getParentComponent ( ) ; 
369+     ThisExpression : function  ( _n )  { 
370+       const  node  =  utils . getParentComponent ( _n ) ; 
371371      if  ( ! node  ||  ! / F u n c t i o n / . test ( node . type ) )  { 
372372        return ; 
373373      } 
@@ -379,7 +379,7 @@ function componentRule(rule, context) {
379379      if  ( ! utils . isReturningJSX ( node ) )  { 
380380        return ; 
381381      } 
382-       const  parentNode  =  utils . getParentComponent ( ) ; 
382+       const  parentNode  =  utils . getParentComponent ( node ) ; 
383383      if  ( ! parentNode )  { 
384384        return ; 
385385      } 
0 commit comments