Skip to content

Conversation

BarryThePenguin
Copy link
Contributor

fixes #885

if (isClass || isArgument) {
return null;
}
// Return the node if it is a function that is not a class method
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should probably be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

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';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misunderstanding what this is checking for here, but I'm not sure this variable name makes sense. I think isJSXExpressionContainerExpression would be more accurate.

Additionally, it might be nice to include a comment with an example of what type of code this identifies.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does this bug exist for folks not using JSX? (i.e. React.createElement)

React.createElement("a", { onClick: function onClick() {
    return props.previousPage();
  } });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that functions inside a JSXExpressionContainer are bing mistaken for stateless components.

For example: <button onClick={() => props.handleClick()}></button>
where {() => props.handleClick()} is theJSXExpressionContainer

@lencioni lencioni merged commit 3e2421e into jsx-eslint:master Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

no-unused-prop-types sometimes fails to detect props in functions on stateless components

2 participants