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

Add no-deprecated-methods rule to prevents usage of deprecated component lifecycle methods #1748

Closed
wants to merge 39 commits into from

Conversation

sergei-startsev
Copy link
Contributor

Here are several component lifecycle methods marked as deprecated in React 16.3 (will be removed in React 17.0):

  • componentWillMount
  • componentWillReceiveProps
  • componentWillUpdate

Please see Gradual Migration Path for details. The rule is intended to prevent usage of these methods.

Rebuilt rule `no-component-will-receive-props`, renamed it to `no-deprecated-methods`, added options to enable/disable particular methods; added docs
@@ -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).
Copy link

@asapach asapach Mar 28, 2018

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.

meta: {
docs: {
description: 'Prevents usage of deprecated component lifecycle methods',
category: 'Possible Errors',
Copy link

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
Copy link
Member

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.

Copy link
Contributor Author

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...

Copy link
Member

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
@sergei-startsev
Copy link
Contributor Author

Closed in favor of #1750

@ljharb
Copy link
Member

ljharb commented Mar 30, 2018

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.

@ljharb ljharb reopened this Mar 30, 2018
@ljharb
Copy link
Member

ljharb commented Jun 17, 2018

This seems to have been improperly rebased; @sergei-startsev, would you mind rebasing it?

@sergei-startsev
Copy link
Contributor Author

Is it still actual? I suppose it has to be closed in favor of #1750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants