From 1818e01c909eadbd9823af090722b0a759c03806 Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Tue, 11 Apr 2017 08:16:54 -0300 Subject: [PATCH 1/4] Add React.createClass to no-deprecated --- lib/rules/no-deprecated.js | 2 ++ tests/lib/rules/no-deprecated.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 4552a4f688..7c098fcbc7 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -64,6 +64,8 @@ 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']; return deprecated; } diff --git a/tests/lib/rules/no-deprecated.js b/tests/lib/rules/no-deprecated.js index 6a775767d1..c395e2aa5a 100644 --- a/tests/lib/rules/no-deprecated.js +++ b/tests/lib/rules/no-deprecated.js @@ -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);', @@ -94,6 +93,11 @@ 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' + }] }] }); From fa44bb251214b65e1fef3087bcccd4786b612afa Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Tue, 11 Apr 2017 08:23:29 -0300 Subject: [PATCH 2/4] Add React.PropTypes to no-deprecated --- lib/rules/no-deprecated.js | 1 + tests/lib/rules/no-deprecated.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 7c098fcbc7..1c6ace661d 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -66,6 +66,7 @@ module.exports = { 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']; return deprecated; } diff --git a/tests/lib/rules/no-deprecated.js b/tests/lib/rules/no-deprecated.js index c395e2aa5a..be5edae408 100644 --- a/tests/lib/rules/no-deprecated.js +++ b/tests/lib/rules/no-deprecated.js @@ -98,6 +98,11 @@ ruleTester.run('no-deprecated', rule, { 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' + }] }] }); From 269bffd98e5a3812086849cd09bf932a39696148 Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Tue, 11 Apr 2017 08:27:57 -0300 Subject: [PATCH 3/4] Update documentation --- docs/rules/no-deprecated.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/rules/no-deprecated.md b/docs/rules/no-deprecated.md index 2ca554168a..8e168543e5 100644 --- a/docs/rules/no-deprecated.md +++ b/docs/rules/no-deprecated.md @@ -16,6 +16,12 @@ React.findDOMNode(this.refs.foo); React.renderToString(); React.renderToStaticMarkup(); + +React.createClass({ /* Class object */ }); + +const propTypes = { + foo: React.PropTypes.bar, +}; ``` The following patterns are not considered warnings: From 3da1140c269e4c8b42931b599b4e034c000defcb Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Tue, 18 Apr 2017 20:58:21 -0300 Subject: [PATCH 4/4] Use pragma option & add more specs --- lib/rules/no-deprecated.js | 4 ++-- tests/lib/rules/no-deprecated.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 1c6ace661d..be063e91da 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -65,8 +65,8 @@ module.exports = { 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']; + 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; } diff --git a/tests/lib/rules/no-deprecated.js b/tests/lib/rules/no-deprecated.js index be5edae408..8ebb3ce847 100644 --- a/tests/lib/rules/no-deprecated.js +++ b/tests/lib/rules/no-deprecated.js @@ -31,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: [{ @@ -98,6 +100,12 @@ ruleTester.run('no-deprecated', rule, { 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: [{