-
-
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
Add no-deprecated-methods
rule to prevents usage of deprecated component lifecycle methods
#1748
Conversation
Rebuilt rule `no-component-will-receive-props`, renamed it to `no-deprecated-methods`, added options to enable/disable particular methods; added docs
docs/rules/no-deprecated-methods.md
Outdated
@@ -0,0 +1,53 @@ | |||
# Prevents usage of deprecated component lifecycle methods (react/no-deprecated-methods) | |||
|
|||
Warns if you have deprecated methods defined when defining a component that extends `React.Component`, `React.PureComponent` or uses ES5 syntax with `createReactClass`. See [React 16.3 details](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path). |
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.
methods defined when defining a component
Phrasing could be improved.
lib/rules/no-deprecated-methods.js
Outdated
meta: { | ||
docs: { | ||
description: 'Prevents usage of deprecated component lifecycle methods', | ||
category: 'Possible Errors', |
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.
no-deprecated
is in 'Best Practices' category - maybe change it for consistency?
README.md
Outdated
@@ -103,6 +103,7 @@ Enable the rules that you would like to use. | |||
* [react/no-danger](docs/rules/no-danger.md): Prevent usage of dangerous JSX properties | |||
* [react/no-danger-with-children](docs/rules/no-danger-with-children.md): Prevent problem with children and props.dangerouslySetInnerHTML | |||
* [react/no-deprecated](docs/rules/no-deprecated.md): Prevent usage of deprecated methods | |||
* [react/no-deprecated-methods](docs/rules/no-deprecated-methods.md): Prevents usage of deprecated component lifecycle methods |
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.
This should be added to no-deprecated
; since that rule already deals with methods, including lifecycle methods.
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.
Could please point to an example of life cycle method in no-deprecated
? I couldn't find any...
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.
There may not be an existing example, but the rule still deals with any depreciations - otherwise it’d be called no-deprecated-static or something :-)
Added warnings for componentWillMount, componentWillReceiveProps, componentWillUpdate
Closed in favor of #1750 |
I’m reopening this so i can sync the refs later to avoid cluttering the git graph; I’ll close it as part of merging #1750. |
[Docs] Typo fixes in jsx-no-target-blank
…ntersection flow types (fixes jsx-eslint#1806)
…ection flow types (fixes jsx-eslint#1806)
…g-state-assignment [Fix] Allow LHS in destructuring-assignment
…tic-proptypes Fix static propTypes handling in no-typos
This seems to have been improperly rebased; @sergei-startsev, would you mind rebasing it? |
Is it still actual? I suppose it has to be closed in favor of #1750 |
Here are several component lifecycle methods marked as deprecated in React 16.3 (will be removed in React 17.0):
Please see Gradual Migration Path for details. The rule is intended to prevent usage of these methods.