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

Disable legacy lifecycle methods linting in scope of no-deprecated rule for now #2069

Merged
merged 1 commit into from Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 0 additions & 27 deletions docs/rules/no-deprecated.md
Expand Up @@ -27,27 +27,6 @@ const propTypes = {
React.DOM.div();

import React, { PropTypes } from 'react';

class Foo extends React.Component {
componentWillMount() { }
componentWillReceiveProps() { }
componentWillUpdate() { }
// ...
}

class Foo extends React.PureComponent {
componentWillMount() { }
componentWillReceiveProps() { }
componentWillUpdate() { }
// ...
}

var Foo = createReactClass({
componentWillMount: function() {},
componentWillReceiveProps: function() {},
componentWillUpdate: function() {},
// ...
})
```

The following patterns are **not** considered warnings:
Expand All @@ -59,10 +38,4 @@ ReactDOM.render(<MyComponent />, root);
ReactDOM.findDOMNode(this.refs.foo);

import { PropTypes } from 'prop-types';

class Foo {
componentWillMount() { }
componentWillReceiveProps() { }
componentWillUpdate() { }
}
```
20 changes: 13 additions & 7 deletions lib/rules/no-deprecated.js
Expand Up @@ -76,21 +76,27 @@ module.exports = {
deprecated[`${pragma}.PropTypes`] = ['15.5.0', 'the npm module prop-types'];
// 15.6.0
deprecated[`${pragma}.DOM`] = ['15.6.0', 'the npm module react-dom-factories'];
// 16.3.0
// 16.999.0
// For now the following life-cycle methods are just legacy, not deprecated:
// `componentWillMount`, `componentWillReceiveProps`, `componentWillUpdate`
// https://github.com/yannickcr/eslint-plugin-react/pull/1750#issuecomment-425975934
deprecated.componentWillMount = [
'16.3.0',
'16.999.0',
Copy link
Member

Choose a reason for hiding this comment

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

these are a semver-patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has to be semver-MINOR, otherwise it doesn't suppress deprecation warnings for the existing React versions (16.3.0 - 16.6.3) where these component lifecycle methods aren't deprecated yet.

Copy link
Member

Choose a reason for hiding this comment

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

why? a minor is for adding new options - this isn't adding a new feature, it's just removing warnings for 16.3-16.6 users. Can you explain more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might have misunderstood your first comment. What semver did you mean? React or eslint-plugin-react? I agree that current PR can be considered as a patch of eslint-plugin-react.

Copy link
Member

Choose a reason for hiding this comment

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

I'm talking about this repo :-)

'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
];
deprecated.componentWillReceiveProps = [
'16.3.0',
'16.999.0',
'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
];
deprecated.componentWillUpdate = [
'16.3.0',
'16.999.0',
'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
];
return deprecated;
}
Expand Down
107 changes: 64 additions & 43 deletions tests/lib/rules/no-deprecated.js
Expand Up @@ -91,7 +91,7 @@ ruleTester.run('no-deprecated', rule, {
componentWillUpdate() {}
}
`,
settings: {react: {version: '16.2.0'}}
settings: {react: {version: '16.998.0'}}
}
],

Expand Down Expand Up @@ -219,25 +219,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 3,
column: 11
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 11
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
Expand All @@ -258,25 +261,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 13
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
column: 13
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 6,
Expand All @@ -295,25 +301,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 3,
column: 11
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 11
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
Expand All @@ -332,25 +341,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 3,
column: 11
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 11
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
Expand All @@ -369,25 +381,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 3,
column: 11
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 11
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
Expand All @@ -406,25 +421,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 3,
column: 11
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 11
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
Expand All @@ -444,25 +462,28 @@ ruleTester.run('no-deprecated', rule, {
errors: [
{
message: errorMessage(
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
'componentWillMount', '16.999.0', 'UNSAFE_componentWillMount',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 4,
column: 11
},
{
message: errorMessage(
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
'componentWillReceiveProps', '16.999.0', 'UNSAFE_componentWillReceiveProps',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 5,
column: 11
},
{
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
message: errorMessage('componentWillUpdate', '16.999.0', 'UNSAFE_componentWillUpdate',
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. ' +
'Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.'
),
type: 'Identifier',
line: 6,
Expand Down