Skip to content

Commit fefcb2d

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 a1193b7 commit fefcb2d

File tree

4 files changed

+33
-93
lines changed

4 files changed

+33
-93
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,
@@ -36,10 +47,10 @@
3647
},
3748

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

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
},
7070
"devDependencies": {
7171
"jest-cli": "0.4.5",
72-
"eslint": "0.9.2"
72+
"babel-eslint": "^3.1.6",
73+
"eslint": "^0.21.2",
74+
"eslint-plugin-react": "^2.3.0"
7375
}
7476
}

0 commit comments

Comments
 (0)