diff --git a/lib/util/Components.js b/lib/util/Components.js index 6c4f18e074..eb2bad5356 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -362,13 +362,14 @@ function componentRule(rule, context) { var isFunction = /Function/.test(node.type); // Functions var isMethod = node.parent && node.parent.type === 'MethodDefinition'; // Classes methods var isArgument = node.parent && node.parent.type === 'CallExpression'; // Arguments (callback, etc.) - var isJSX = node.parent && node.parent.type === 'JSXExpressionContainer'; + // Attribute Expressions inside JSX Elements () + var isJSXExpressionContainer = node.parent && node.parent.type === 'JSXExpressionContainer'; // Stop moving up if we reach a class or an argument (like a callback) if (isClass || isArgument) { return null; } - // Return the node if it is a function that is not a class method - if (isFunction && !isMethod && !isJSX) { + // Return the node if it is a function that is not a class method and is not inside a JSX Element + if (isFunction && !isMethod && !isJSXExpressionContainer) { return node; } scope = scope.upper;