Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positives inside lifecycle methods #2099

Merged
merged 1 commit into from Dec 30, 2018

Conversation

jomasti
Copy link
Contributor

@jomasti jomasti commented Dec 28, 2018

This will prevent triggering on any member expression inside a lifecycle
method. Instead, it will do the naive checking of the node names for
props, nextProps, and prevProps which is already done here.

Resolves #2094. Resolves #2095.

This will prevent triggering on any member expression inside a lifecycle
method. Instead, it will do the naive checking of the node names for
`props`, `nextProps`, and `prevProps` which is already done here.
@@ -285,13 +285,14 @@ module.exports = function usedPropTypesInstructions(context, components, utils)
* @returns {Boolean} True if we are using a prop, false if not.
*/
function isPropTypesUsage(node) {
const isThisPropsUsage = node.object.type === 'ThisExpression' && node.property.name === 'props';
const isPropsUsage = isThisPropsUsage || node.object.name === 'nextProps' || node.object.name === 'prevProps';
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix!
Later on it'd be great not to depend on the names (similar to #1829), but for now not crashing is the priority 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed!

@ljharb ljharb added the bug label Dec 30, 2018
@ljharb ljharb merged commit dfeeb81 into jsx-eslint:master Dec 30, 2018
@jomasti jomasti deleted the issue-2094 branch December 30, 2018 00:41
@paulmelnikow
Copy link

Hi! Thanks so much for your work on this plugin.

We're running into this issue at badges/shields#2609. Could this be released?

@ljharb
Copy link
Member

ljharb commented Jan 1, 2019

v7.12.1 is released.

This was referenced Jan 1, 2019
This was referenced Jan 7, 2019
@ghost ghost mentioned this pull request Jan 12, 2019
1 task
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.

None yet

4 participants