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

Update no-unused-prop-types rule for new React class component lifecycles #1681

Merged
merged 2 commits into from Mar 9, 2018

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Feb 7, 2018

The upcoming React 16.3 release will make a couple of changes to the class component lifecycles: componentWillMount, componentWillReceiveProps, and componentWillUpdate are being aliased to UNSAFE_componentWillMount, UNSAFE_componentWillReceiveProps, and UNSAFE_componentWillUpdate and a new static lifecycle, getDerivedStateFromProps, is being added.

For background information, see RFC 6.

When running codemods at Facebook to rename these lifecycles, I noticed that it caused a couple of false positives with the react/no-unused-prop-types lint rule since that rule was not yet aware of the lifecycle changes. I think this PR corrects that. I added a couple of sanity check tests (which failed before my changes) to verify this.

'componentDidUpdate',
'componentWillReceiveProps',
'componentWillUpdate',
'getDerivedStateFromProps',
Copy link
Member

Choose a reason for hiding this comment

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

these new methods should only be checked if the React version pragma from settings is >= 16.3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes. Thanks for pointing that out.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dhananjaypuglia
Copy link

Can we get this PR merged ?

@rgabs
Copy link

rgabs commented Mar 7, 2018

I checked the PR and it works. Could you please merge this PR?

@ljharb ljharb merged commit 14b8d01 into jsx-eslint:master Mar 9, 2018
cemjotform added a commit to jotform/jotform-linter-configs that referenced this pull request Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants