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
Conversation
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'; |
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
Hi! Thanks so much for your work on this plugin. We're running into this issue at badges/shields#2609. Could this be released? |
v7.12.1 is released. |
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
, andprevProps
which is already done here.Resolves #2094. Resolves #2095.