Skip to content

Commit

Permalink
Remove rules deprecated options
Browse files Browse the repository at this point in the history
  • Loading branch information
lencioni authored and yannickcr committed Jul 24, 2016
1 parent 58b69e5 commit 00cdab8
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 72 deletions.
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 = [];
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

0 comments on commit 00cdab8

Please sign in to comment.