-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fixes a few false positive failures in the no-unused-prop-types
rule
#792
Fixes a few false positive failures in the no-unused-prop-types
rule
#792
Conversation
' }', | ||
' constructor (props) {', | ||
' super(props);', | ||
' const {something} = props;', |
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.
can we also test all these cases with the destructuring being done inline in the signature? ie, constructor ({ something }) {
?
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.
Done!
070b489
to
42ce491
Compare
42ce491
to
3d09075
Compare
Test cases LGTM. |
Merged, thanks! |
@EvNaverniouk hi, i wonder know why must i use destructured props: |
You don't have to; this just ensures it works if you do. |
@ljharb if i don't do it in this way, it goes wrong. is this config correct ? |
Using nextProps with an object spread operator doesn't prevent the no-unused-proptypes error (even though all props are used), I assume that's by design? (Since it's still only a proposal) |
The rule has no way of knowing what props you are using there because it can't know what properties are on it at runtime. Using object spread is dynamic; prefer explicit prop referencing. |
Ah yeah of course. That makes sense. |
Fixes several false positives failures in the
no-unused-prop-types
rules:nextProps
andprevProps
property names in lifecycle methods are correctly counted towards used propsno-unused-prop-types
doesn't checknextProps
ofcomponentWillReceiveProps
#801