Skip to content

Commit 9af8d25

Browse files
fix comments
1 parent d5c3e91 commit 9af8d25

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/util/Components.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,14 @@ function componentRule(rule, context) {
362362
var isFunction = /Function/.test(node.type); // Functions
363363
var isMethod = node.parent && node.parent.type === 'MethodDefinition'; // Classes methods
364364
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';
366367
// Stop moving up if we reach a class or an argument (like a callback)
367368
if (isClass || isArgument) {
368369
return null;
369370
}
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) {
372373
return node;
373374
}
374375
scope = scope.upper;

0 commit comments

Comments
 (0)