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 all 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[pragma + '.createClass'] = ['15.5.0', 'the npm module create-react-class'];
deprecated.MemberExpression[pragma + '.PropTypes'] = ['15.5.0', 'the npm module prop-types'];

return deprecated;
}
Expand Down
21 changes: 19 additions & 2 deletions 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 All @@ -32,7 +31,9 @@ ruleTester.run('no-deprecated', rule, {
'ReactDOMServer.renderToString(element);',
'ReactDOMServer.renderToStaticMarkup(element);',
// Deprecated in a later version
{code: 'React.renderComponent()', settings: {react: {version: '0.11.0'}}}
{code: 'React.renderComponent()', settings: {react: {version: '0.11.0'}}},
{code: 'React.createClass()', settings: {react: {version: '15.4.0'}}},
{code: 'React.PropTypes', settings: {react: {version: '15.4.0'}}}
],

invalid: [{
Expand Down Expand Up @@ -94,6 +95,22 @@ 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: 'Foo.createClass({});',
settings: {react: {pragma: 'Foo'}},
errors: [{
message: 'Foo.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'
}]
}]

});