Skip to content

Commit

Permalink
Merge pull request #2069 from sergei-startsev/legacy-lifecycle-methods
Browse files Browse the repository at this point in the history
[patch] Disable legacy lifecycle methods linting in scope of `no-deprecated` rule for now
  • Loading branch information
ljharb committed Dec 7, 2018
2 parents a33bfb1 + 70d4e71 commit 35c0b4d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 77 deletions.
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',
'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

0 comments on commit 35c0b4d

Please sign in to comment.