Skip to content

Commit

Permalink
Update codebase for ESLint v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jul 15, 2015
1 parent 4a91497 commit 04e0518
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 279 deletions.
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"no-debugger": 2,
"no-dupe-keys": 2,
"no-empty": 2,
"no-empty-class": 2,
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
Expand Down Expand Up @@ -132,7 +132,6 @@
"no-trailing-spaces": 2,
"no-multiple-empty-lines": 2,
"no-underscore-dangle": 0,
"no-wrap-func": 2,
"one-var": 0,
"operator-assignment": [2, "always"],
"padded-blocks": 0,
Expand All @@ -142,12 +141,13 @@
"sort-vars": [2, {"ignoreCase": true}],
"space-after-keywords": 2,
"space-before-blocks": 2,
"space-in-brackets": 2,
"object-curly-spacing": [2, "never"],
"array-bracket-spacing": [2, "never"],
"space-in-parens": 2,
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": 2,
"spaced-line-comment": 2,
"spaced-comment": 2,
"wrap-regex": 0,
// Legacy
"max-depth": 0,
Expand Down
12 changes: 6 additions & 6 deletions lib/rules/jsx-no-undef.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ module.exports = function(context) {
}

return {
JSXOpeningElement: function(node) {
if (isTagName(node.name.name)) {
return;
}
checkIdentifierInJSX(node.name);
}
JSXOpeningElement: function(node) {
if (isTagName(node.name.name)) {
return;
}
checkIdentifierInJSX(node.name);
}
};

};
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"description": "React specific linting rules for ESLint",
"main": "index.js",
"scripts": {
"test": "npm run lint && npm run unit-test",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls",
"lint": "eslint ./",
"unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --reporter dot",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls"
"test": "npm run lint && npm run unit-test",
"unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --reporter dot"
},
"files": [
"LICENSE",
Expand All @@ -23,9 +23,9 @@
"homepage": "https://github.com/yannickcr/eslint-plugin-react",
"bugs": "https://github.com/yannickcr/eslint-plugin-react/issues",
"devDependencies": {
"babel-eslint": "3.1.19",
"babel-eslint": "3.1.23",
"coveralls": "2.11.2",
"eslint": "0.24.0",
"eslint": "1.0.0-rc-1",
"eslint-tester": "0.8.2",
"istanbul": "0.3.17",
"mocha": "2.2.5"
Expand All @@ -34,9 +34,9 @@
"eslint": ">=0.8.0"
},
"keywords": [
"eslint",
"eslint-plugin",
"eslintplugin",
"eslint",
"react"
],
"license": "MIT"
Expand Down
20 changes: 10 additions & 10 deletions tests/lib/rules/jsx-boolean-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ var ESLintTester = require('eslint-tester');

var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/jsx-boolean-value', {
valid: [
{code: '<App foo />;', args: [1, 'never'], ecmaFeatures: {jsx: true}},
{code: '<App foo={true} />;', args: [1, 'always'], ecmaFeatures: {jsx: true}}
],
invalid: [
{code: '<App foo={true} />;', args: [1, 'never'],
errors: [{message: 'Value must be omitted for boolean attributes'}], ecmaFeatures: {jsx: true}},
{code: '<App foo />;', args: [1, 'always'],
errors: [{message: 'Value must be set for boolean attributes'}], ecmaFeatures: {jsx: true}}
]
valid: [
{code: '<App foo />;', args: [1, 'never'], ecmaFeatures: {jsx: true}},
{code: '<App foo={true} />;', args: [1, 'always'], ecmaFeatures: {jsx: true}}
],
invalid: [
{code: '<App foo={true} />;', args: [1, 'never'],
errors: [{message: 'Value must be omitted for boolean attributes'}], ecmaFeatures: {jsx: true}},
{code: '<App foo />;', args: [1, 'always'],
errors: [{message: 'Value must be set for boolean attributes'}], ecmaFeatures: {jsx: true}}
]
});
26 changes: 13 additions & 13 deletions tests/lib/rules/jsx-quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ var ESLintTester = require('eslint-tester');

var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/jsx-quotes', {
valid: [
{code: '<App foo=\'bar\' />;', args: [1, 'single'], ecmaFeatures: {jsx: true}},
{code: '<App foo="bar" />;', args: [1, 'double'], ecmaFeatures: {jsx: true}},
{code: '<App foo="ba\'r" />;', args: [1, 'single', 'avoid-escape'], ecmaFeatures: {jsx: true}},
{code: '<App foo=\'ba"r\' />;', args: [1, 'double', 'avoid-escape'], ecmaFeatures: {jsx: true}},
{code: '<App>foo</App>;', args: [1, 'single'], ecmaFeatures: {jsx: true}}
],
invalid: [
{code: '<App foo="bar" />;',
errors: [{message: 'JSX attributes must use singlequote.'}], args: [1, 'single'], ecmaFeatures: {jsx: true}},
{code: '<App foo=\'bar\' />;',
errors: [{message: 'JSX attributes must use doublequote.'}], args: [1, 'double'], ecmaFeatures: {jsx: true}}
]
valid: [
{code: '<App foo=\'bar\' />;', args: [1, 'single'], ecmaFeatures: {jsx: true}},
{code: '<App foo="bar" />;', args: [1, 'double'], ecmaFeatures: {jsx: true}},
{code: '<App foo="ba\'r" />;', args: [1, 'single', 'avoid-escape'], ecmaFeatures: {jsx: true}},
{code: '<App foo=\'ba"r\' />;', args: [1, 'double', 'avoid-escape'], ecmaFeatures: {jsx: true}},
{code: '<App>foo</App>;', args: [1, 'single'], ecmaFeatures: {jsx: true}}
],
invalid: [
{code: '<App foo="bar" />;',
errors: [{message: 'JSX attributes must use singlequote.'}], args: [1, 'single'], ecmaFeatures: {jsx: true}},
{code: '<App foo=\'bar\' />;',
errors: [{message: 'JSX attributes must use doublequote.'}], args: [1, 'double'], ecmaFeatures: {jsx: true}}
]
});
6 changes: 3 additions & 3 deletions tests/lib/rules/jsx-sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ eslintTester.addRuleTest('lib/rules/jsx-sort-prop-types', {
errors: [{
message: ERROR_MESSAGE,
line: 4,
column: 4,
column: 5,
type: 'Property'
}]
}, {
Expand All @@ -234,7 +234,7 @@ eslintTester.addRuleTest('lib/rules/jsx-sort-prop-types', {
errors: [{
message: ERROR_MESSAGE,
line: 4,
column: 4,
column: 5,
type: 'Property'
}]
}, {
Expand All @@ -258,7 +258,7 @@ eslintTester.addRuleTest('lib/rules/jsx-sort-prop-types', {
errors: [{
message: ERROR_MESSAGE,
line: 4,
column: 4,
column: 5,
type: 'Property'
}]
}, {
Expand Down
24 changes: 12 additions & 12 deletions tests/lib/rules/jsx-uses-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ var ESLintTester = require('eslint-tester');
var eslintTester = new ESLintTester(eslint);
eslint.defineRule('jsx-uses-react', require('../../../lib/rules/jsx-uses-react'));
eslintTester.addRuleTest('node_modules/eslint/lib/rules/no-unused-vars', {
valid: [
{code: '/*eslint jsx-uses-react:1*/ var React; <div />;', ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:1*/ var React; (function () { <div /> })();', ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:1*/ /** @jsx Foo */ var Foo; <div />;', ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:[1,{"pragma":"Foo"}]*/ var Foo; <div />;', ecmaFeatures: {jsx: true}}
],
invalid: [
{code: '/*eslint jsx-uses-react:1*/ var React;',
errors: [{message: 'React is defined but never used'}], ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:1*/ /** @jsx Foo */ var React; <div />;',
errors: [{message: 'React is defined but never used'}], ecmaFeatures: {jsx: true}}
]
valid: [
{code: '/*eslint jsx-uses-react:1*/ var React; <div />;', ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:1*/ var React; (function () { <div /> })();', ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:1*/ /** @jsx Foo */ var Foo; <div />;', ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:[1,{"pragma":"Foo"}]*/ var Foo; <div />;', ecmaFeatures: {jsx: true}}
],
invalid: [
{code: '/*eslint jsx-uses-react:1*/ var React;',
errors: [{message: 'React is defined but never used'}], ecmaFeatures: {jsx: true}},
{code: '/*eslint jsx-uses-react:1*/ /** @jsx Foo */ var React; <div />;',
errors: [{message: 'React is defined but never used'}], ecmaFeatures: {jsx: true}}
]
});
3 changes: 1 addition & 2 deletions tests/lib/rules/no-danger.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ eslintTester.addRuleTest('lib/rules/no-danger', {
code: '<div dangerouslySetInnerHTML={{ __html: "" }}></div>;',
errors: [{message: 'Dangerous property \'dangerouslySetInnerHTML\' found'}],
ecmaFeatures: {jsx: true}
}
]
}]
});
12 changes: 6 additions & 6 deletions tests/lib/rules/no-did-mount-set-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ eslintTester.addRuleTest('lib/rules/no-did-mount-set-state', {
code: [
'var Hello = React.createClass({',
' componentDidMount: function() {',
' this.setState({',
' data: data',
' });',
' this.setState({',
' data: data',
' });',
' }',
'});'
].join('\n'),
Expand All @@ -108,9 +108,9 @@ eslintTester.addRuleTest('lib/rules/no-did-mount-set-state', {
code: [
'var Hello = React.createClass({',
' componentDidMount: function() {',
' this.setState({',
' data: data',
' });',
' this.setState({',
' data: data',
' });',
' }',
'});'
].join('\n'),
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/no-unknown-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ eslintTester.addRuleTest('lib/rules/no-unknown-property', {
code: '<div class="bar"></div>;',
errors: [{message: 'Unknown property \'class\' found, use \'className\' instead'}],
ecmaFeatures: {jsx: true}
}, {
}, {
code: '<div for="bar"></div>;',
errors: [{message: 'Unknown property \'for\' found, use \'htmlFor\' instead'}],
ecmaFeatures: {jsx: true}
}, {
}, {
code: '<div accept-charset="bar"></div>;',
errors: [{message: 'Unknown property \'accept-charset\' found, use \'acceptCharset\' instead'}],
ecmaFeatures: {jsx: true}
}, {
}, {
code: '<div http-equiv="bar"></div>;',
errors: [{message: 'Unknown property \'http-equiv\' found, use \'httpEquiv\' instead'}],
ecmaFeatures: {jsx: true}
}, {
}, {
code: '<div accesskey="bar"></div>;',
errors: [{message: 'Unknown property \'accesskey\' found, use \'accessKey\' instead'}],
ecmaFeatures: {jsx: true}}
Expand Down
9 changes: 5 additions & 4 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
classes: true,
jsx: true
}
}],
}
],

invalid: [
{
Expand All @@ -600,7 +601,7 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
errors: [{
message: '\'name\' is missing in props validation',
line: 3,
column: 53,
column: 54,
type: 'Identifier'
}]
}, {
Expand All @@ -617,7 +618,7 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
errors: [{
message: '\'name\' is missing in props validation',
line: 3,
column: 34,
column: 35,
type: 'Identifier'
}]
}, {
Expand All @@ -635,7 +636,7 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
errors: [{
message: '\'name\' is missing in props validation for Hello',
line: 3,
column: 34,
column: 35,
type: 'Identifier'
}]
}, {
Expand Down
74 changes: 39 additions & 35 deletions tests/lib/rules/react-in-jsx-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,43 @@ var ESLintTester = require('eslint-tester');

var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/react-in-jsx-scope', {
valid: [
{code: 'var React, App; <App />;', ecmaFeatures: {jsx: true}},
{code: 'var React; <img />;', ecmaFeatures: {jsx: true}},
{code: 'var React; <x-gif />;', ecmaFeatures: {jsx: true}},
{code: 'var React, App, a=1; <App attr={a} />;', ecmaFeatures: {jsx: true}},
{code: 'var React, App, a=1; function elem() { return <App attr={a} />; }', ecmaFeatures: {jsx: true}},
{code: 'var React, App; <App />;', ecmaFeatures: {globalReturn: true, jsx: true}},
{code: '/** @jsx Foo */ var Foo, App; <App />;', ecmaFeatures: {jsx: true}},
{code: '/** @jsx Foo.Bar */ var Foo, App; <App />;', ecmaFeatures: {jsx: true}},
{code: [
'import React from \'react/addons\';',
'const Button = React.createClass({',
' render() {',
' return (',
' <button {...this.props}>{this.props.children}</button>',
' )',
' }',
'});',
'export default Button;'
].join('\n'),
ecmaFeatures: {blockBindings: true, objectLiteralShorthandMethods: true, modules: true, jsx: true}
}
],
invalid: [
{code: 'var App, a = <App />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: 'var a = <App />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: 'var a = <img />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: '/** @jsx React.DOM */ var a = <img />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: '/** @jsx Foo.bar */ var React, a = <img />;',
errors: [{message: '\'Foo\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}}
]
valid: [
{code: 'var React, App; <App />;', ecmaFeatures: {jsx: true}},
{code: 'var React; <img />;', ecmaFeatures: {jsx: true}},
{code: 'var React; <x-gif />;', ecmaFeatures: {jsx: true}},
{code: 'var React, App, a=1; <App attr={a} />;', ecmaFeatures: {jsx: true}},
{code: 'var React, App, a=1; function elem() { return <App attr={a} />; }', ecmaFeatures: {jsx: true}},
{code: 'var React, App; <App />;', ecmaFeatures: {globalReturn: true, jsx: true}},
{code: '/** @jsx Foo */ var Foo, App; <App />;', ecmaFeatures: {jsx: true}},
{code: '/** @jsx Foo.Bar */ var Foo, App; <App />;', ecmaFeatures: {jsx: true}},
{code: [
'import React from \'react/addons\';',
'const Button = React.createClass({',
' render() {',
' return (',
' <button {...this.props}>{this.props.children}</button>',
' )',
' }',
'});',
'export default Button;'
].join('\n'),
ecmaFeatures: {
blockBindings: true,
objectLiteralShorthandMethods: true,
modules: true,
jsx: true
}}
],
invalid: [
{code: 'var App, a = <App />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: 'var a = <App />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: 'var a = <img />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: '/** @jsx React.DOM */ var a = <img />;',
errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
{code: '/** @jsx Foo.bar */ var React, a = <img />;',
errors: [{message: '\'Foo\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}}
]
});
Loading

0 comments on commit 04e0518

Please sign in to comment.