Skip to content

Commit 2ae438c

Browse files
committed
[Lint] Update linter to use babel-lint and lint JSX/React directly
- Upgraded eslint - Installed babel-eslint so that we can parse JSX and ES6 - Installed eslint-react-plugin so we can lint JSX directly w/o a transform - `no-comma-dangle` was replaced with `comma-dangle` - `space-unary-word-ops` was replaced with `space-unary-ops`.
1 parent b99744a commit 2ae438c

File tree

4 files changed

+34
-94
lines changed

4 files changed

+34
-94
lines changed

.eslintrc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
{
2+
"parser": "babel-eslint",
3+
4+
"ecmaFeatures": {
5+
"jsx": true
6+
},
7+
28
"env": {
9+
"es6": true,
310
"jasmine": true,
411
},
512

13+
"plugins": [
14+
"react"
15+
],
16+
617
// Map from global var to bool specifying if it can be redefined
718
"globals": {
819
"__DEV__": true,
@@ -35,10 +46,10 @@
3546
},
3647

3748
"rules": {
49+
"comma-dangle": 0, // disallow trailing commas in object literals
3850
"no-cond-assign": 1, // disallow assignment in conditional expressions
3951
"no-console": 0, // disallow use of console (off by default in the node environment)
4052
"no-constant-condition": 0, // disallow use of constant expressions in conditions
41-
"no-comma-dangle": 0, // disallow trailing commas in object literals
4253
"no-control-regex": 1, // disallow control characters in regular expressions
4354
"no-debugger": 1, // disallow use of debugger
4455
"no-dupe-keys": 1, // disallow duplicate keys when creating object literals
@@ -176,7 +187,7 @@
176187
"space-in-parens": 0, // require or disallow spaces inside parentheses (off by default)
177188
"space-infix-ops": 1, // require spaces around operators
178189
"space-return-throw-case": 1, // require a space after return, throw, and case
179-
"space-unary-word-ops": 1, // require a space around word operators such as typeof (off by default)
190+
"space-unary-ops": [1, { "words": true, "nonwords": false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
180191
"max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default)
181192
"one-var": 0, // allow just one var statement per function (off by default)
182193
"wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
@@ -189,6 +200,22 @@
189200
"max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default)
190201
"max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
191202
"no-bitwise": 1, // disallow use of bitwise operators (off by default)
192-
"no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default)
203+
"no-plusplus": 0, // disallow use of unary operators, ++ and -- (off by default)
204+
205+
"react/display-name": 0,
206+
"react/jsx-boolean-value": 0,
207+
"react/jsx-quotes": [1, "double", "avoid-escape"],
208+
"react/jsx-no-undef": 1,
209+
"react/jsx-sort-props": 0,
210+
"react/jsx-uses-react": 0,
211+
"react/jsx-uses-vars": 1,
212+
"react/no-did-mount-set-state": 0,
213+
"react/no-did-update-set-state": 0,
214+
"react/no-multi-comp": 0,
215+
"react/no-unknown-property": 0,
216+
"react/prop-types": 0,
217+
"react/react-in-jsx-scope": 0,
218+
"react/self-closing-comp": 1,
219+
"react/wrap-multilines": 0
193220
}
194221
}

lint/linterTransform.js

Lines changed: 0 additions & 84 deletions
This file was deleted.

linter.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,5 @@
88
*/
99
'use strict';
1010

11-
var transformSource = require('./jestSupport/scriptPreprocess.js').transformSource;
12-
var linterTransform = require('./lint/linterTransform');
13-
14-
linterTransform.setLinterTransform(transformSource);
15-
1611
// Run the original CLI
1712
require('eslint/bin/eslint');

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
"yargs": "1.3.2"
6868
},
6969
"devDependencies": {
70-
"jest-cli": "0.2.1",
71-
"eslint": "0.9.2"
70+
"babel-eslint": "^3.0.1",
71+
"eslint": "^0.19.0",
72+
"eslint-plugin-react": "^2.1.1",
73+
"jest-cli": "0.2.1"
7274
}
7375
}

0 commit comments

Comments
 (0)