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

Remove rules deprecated options #700

Merged
merged 2 commits into from
Jul 24, 2016
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
23 changes: 1 addition & 22 deletions docs/rules/jsx-uses-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ If you are using the @jsx pragma this rule will mark the designated variable and

This rule has no effect if the `no-unused-vars` rule is not enabled.

You can use the [shared settings](/README.md#configuration) to specify a custom pragma.

## Rule Details

Expand Down Expand Up @@ -40,28 +41,6 @@ var Foo = require('foo');
var Hello = <div>Hello {this.props.name}</div>;
```

## Rule Options

```js
...
"jsx-uses-react": [<enabled>, { "pragma": <string> }]
...
```

### `pragma`

**Deprecation notice**: This option is deprecated, please use the [shared settings](/README.md#configuration) to specify a custom pragma.

As an alternative to specifying the above pragma in each source file, you can specify
this configuration option:

```js
var Foo = require('Foo');

var Hello = <div>Hello {this.props.name}</div>;
```


## When Not To Use It

If you are not using JSX, if React is declared as global variable or if you do not use the `no-unused-vars` rule then you can disable this rule.
14 changes: 1 addition & 13 deletions docs/rules/no-deprecated.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prevent usage of deprecated methods (no-deprecated)

Several methods are deprecated between React versions. This rule will warn you if you try to use a deprecated method.
Several methods are deprecated between React versions. This rule will warn you if you try to use a deprecated method. Use the [shared settings](/README.md#configuration) to specify the React version.

## Rule Details

Expand All @@ -26,15 +26,3 @@ ReactDOM.render(<MyComponent />, root);
// When [1, {"react": "0.13.0"}]
ReactDOM.findDOMNode(this.refs.foo);
```

## Rule Options

**Deprecation notice**: This option is deprecated, please use the [shared settings](/README.md#configuration) to specify the React version.

By default this rule will warn to every methods marked as deprecated. You can limit it to an older React version if you are not using the latest one:

```js
"rules": {
"react/no-deprecated": [1, {"react": "0.12.0"}] // Will warn for every deprecated methods in React 0.12.0 and below
}
```
10 changes: 1 addition & 9 deletions lib/rules/jsx-uses-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,4 @@ module.exports = function(context) {

};

module.exports.schema = [{
type: 'object',
properties: {
pragma: {
type: 'string'
}
},
additionalProperties: false
}];
module.exports.schema = [];
Copy link
Member

Choose a reason for hiding this comment

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

if you supply an option when the schema is [], does it error out? ie, does it have additionalProperties: false behavior implicitly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just tried this out with a different rule that has a schema of [] and it produced an error like:

Configuration for rule "plugin/rule" is invalid:
Value "config value" has more items than allowed.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, thanks for confirming :-)

11 changes: 1 addition & 10 deletions lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,4 @@ module.exports = function(context) {

};

module.exports.schema = [{
type: 'object',
properties: {
react: {
type: 'string',
pattern: '^[0-9]+\.[0-9]+(\.[0-9]+)?$'
}
},
additionalProperties: false
}];
module.exports.schema = [];
3 changes: 0 additions & 3 deletions lib/util/pragma.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ function getFromContext(context) {
// .eslintrc shared settings (http://eslint.org/docs/user-guide/configuring#adding-shared-settings)
if (context.settings.react && context.settings.react.pragma) {
pragma = context.settings.react.pragma;
// Deprecated pragma option, here for backward compatibility
} else if (context.options[0] && context.options[0].pragma) {
pragma = context.options[0].pragma;
}
return pragma.split('.')[0];
}
Expand Down
3 changes: 0 additions & 3 deletions lib/util/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ function getFromContext(context) {
// .eslintrc shared settings (http://eslint.org/docs/user-guide/configuring#adding-shared-settings)
if (context.settings.react && context.settings.react.version) {
confVer = context.settings.react.version;
// Deprecated react option, here for backward compatibility
} else if (context.options[0] && context.options[0].react) {
confVer = context.options[0].react;
}
confVer = /^[0-9]+\.[0-9]+$/.test(confVer) ? confVer + '.0' : confVer;
return confVer.split('.').map(function(part) {
Expand Down
1 change: 0 additions & 1 deletion tests/lib/rules/jsx-uses-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ ruleTester.run('no-unused-vars', rule, {
{code: '/*eslint jsx-uses-react:1*/ var React; <div />;', parserOptions: parserOptions},
{code: '/*eslint jsx-uses-react:1*/ var React; (function () { <div /> })();', parserOptions: parserOptions},
{code: '/*eslint jsx-uses-react:1*/ /** @jsx Foo */ var Foo; <div />;', parserOptions: parserOptions},
{code: '/*eslint jsx-uses-react:[1,{"pragma":"Foo"}]*/ var Foo; <div />;', parserOptions: parserOptions},
{code: '/*eslint jsx-uses-react:1*/ var Foo; <div />;', settings: settings, parserOptions: parserOptions}
],
invalid: [
Expand Down
14 changes: 3 additions & 11 deletions tests/lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
var rule = require('../../../lib/rules/no-deprecated');
var RuleTester = require('eslint').RuleTester;

var settings = {
react: {
pragma: 'Foo'
}
};

require('babel-eslint');

// ------------------------------------------------------------------------------
Expand All @@ -38,26 +32,24 @@ ruleTester.run('no-deprecated', rule, {
'ReactDOMServer.renderToString(element);',
'ReactDOMServer.renderToStaticMarkup(element);',
// Deprecated in a later version
{code: 'React.renderComponent()', options: [{react: '0.11.0'}]},
{code: 'React.renderComponent()', settings: {react: {version: '0.11.0'}}}
],

invalid: [{
code: 'React.renderComponent()',
options: [{react: '0.12.0'}],
settings: {react: {version: '0.12.0'}},
errors: [{
message: 'React.renderComponent is deprecated since React 0.12.0, use React.render instead'
}]
}, {
code: 'Foo.renderComponent()',
options: [{react: '0.12.0'}],
settings: settings,
settings: {react: {pragma: 'Foo', version: '0.12.0'}},
errors: [{
message: 'Foo.renderComponent is deprecated since React 0.12.0, use Foo.render instead'
}]
}, {
code: '/** @jsx Foo */ Foo.renderComponent()',
options: [{react: '0.12.0'}],
settings: {react: {version: '0.12.0'}},
errors: [{
message: 'Foo.renderComponent is deprecated since React 0.12.0, use Foo.render instead'
}]
Expand Down