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 new deprecations from 15.5.0 #1148

Merged
merged 4 commits into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/rules/no-deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ React.findDOMNode(this.refs.foo);
React.renderToString(<MyComponent />);

React.renderToStaticMarkup(<MyComponent />);

React.createClass({ /* Class object */ });

const propTypes = {
foo: React.PropTypes.bar,
};
```

The following patterns are not considered warnings:
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ module.exports = {
deprecated.MemberExpression['Perf.printDOM'] = ['15.0.0', 'Perf.printOperations'];
deprecated.MemberExpression['ReactPerf.getMeasurementsSummaryMap'] = ['15.0.0', 'ReactPerf.getWasted'];
deprecated.MemberExpression['Perf.getMeasurementsSummaryMap'] = ['15.0.0', 'Perf.getWasted'];
// 15.5.0
deprecated.MemberExpression['React.createClass'] = ['15.5.0', 'the npm module create-react-class'];
deprecated.MemberExpression['React.PropTypes'] = ['15.5.0', 'the npm module prop-types'];
Copy link
Member

Choose a reason for hiding this comment

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

Please use the pragma variable instead of the hardcoded React string (you can take the other deprecation as example).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pragma would match if there is other thing than React.* used right?
I don't think it should match if this is from another object than React.

Copy link
Member

Choose a reason for hiding this comment

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

pragma will match other thing than React only if the user has customized it to match something else (with a comment or using the shared settings).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it 👍 PR updated


return deprecated;
}
Expand Down
11 changes: 10 additions & 1 deletion tests/lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ruleTester.run('no-deprecated', rule, {

valid: [
// Not deprecated
'var MyClass = React.createClass({});',
'var element = React.createElement(\'p\', {}, null);',
'var clone = React.cloneElement(element);',
'ReactDOM.render(element, container);',
Expand Down Expand Up @@ -94,6 +93,16 @@ ruleTester.run('no-deprecated', rule, {
'use ReactDOMServer.renderToStaticMarkup instead'
)
}]
}, {
code: 'React.createClass({});',
errors: [{
message: 'React.createClass is deprecated since React 15.5.0, use the npm module create-react-class instead'
}]
}, {
code: 'React.PropTypes',
errors: [{
message: 'React.PropTypes is deprecated since React 15.5.0, use the npm module prop-types instead'
}]
}]

});