File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -362,13 +362,14 @@ function componentRule(rule, context) {
362
362
var isFunction = / F u n c t i o n / . test ( node . type ) ; // Functions
363
363
var isMethod = node . parent && node . parent . type === 'MethodDefinition' ; // Classes methods
364
364
var isArgument = node . parent && node . parent . type === 'CallExpression' ; // Arguments (callback, etc.)
365
- var isJSX = node . parent && node . parent . type === 'JSXExpressionContainer' ;
365
+ // Attribute Expressions inside JSX Elements (<button onClick={() => props.handleClick()}></button>)
366
+ var isJSXExpressionContainer = node . parent && node . parent . type === 'JSXExpressionContainer' ;
366
367
// Stop moving up if we reach a class or an argument (like a callback)
367
368
if ( isClass || isArgument ) {
368
369
return null ;
369
370
}
370
- // Return the node if it is a function that is not a class method
371
- if ( isFunction && ! isMethod && ! isJSX ) {
371
+ // Return the node if it is a function that is not a class method and is not inside a JSX Element
372
+ if ( isFunction && ! isMethod && ! isJSXExpressionContainer ) {
372
373
return node ;
373
374
}
374
375
scope = scope . upper ;
You can’t perform that action at this time.
0 commit comments