Skip to content

Commit cbc8638

Browse files
committedDec 19, 2016
Build: ESLint setup improvements
1. Use the short name of the preset in the config. 2. Run ESLint first on non-minified files. 3. Explicitly specify environments in every config file (those settings cascade which means we've been assuming a Node.js environment where we shouldn't have).
1 parent 5d79c64 commit cbc8638

File tree

9 files changed

+88
-36
lines changed

9 files changed

+88
-36
lines changed
 

Diff for: ‎.eslintrc-browser.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"root": true,
3+
4+
"extends": "jquery",
5+
6+
// Support: IE <=9 only, Android <=4.0 only
7+
// The above browsers are failing a lot of tests in the ES5
8+
// test suite at http://test262.ecmascript.org.
9+
"parserOptions": {
10+
"ecmaVersion": 3
11+
},
12+
13+
// The browser env is not enabled on purpose so that code takes
14+
// all browser-only globals from window instead of assuming
15+
// they're available as globals. This makes it possible to use
16+
// jQuery with tools like jsdom which provide a custom window
17+
// implementation.
18+
"env": {},
19+
20+
"globals": {
21+
"window": true,
22+
"jQuery": true,
23+
"define": true,
24+
"module": true,
25+
"noGlobal": true
26+
},
27+
28+
"rules": {
29+
"strict": ["error", "function"]
30+
}
31+
}

Diff for: ‎.eslintrc-node.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"root": true,
3+
4+
"extends": "jquery",
5+
6+
"parserOptions": {
7+
"ecmaVersion": 5
8+
},
9+
10+
"env": {
11+
"node": true
12+
}
13+
}

Diff for: ‎.eslintrc.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"extends": "eslint-config-jquery",
32
"root": true,
4-
"env": {
5-
"node": true
6-
}
3+
4+
"extends": "./.eslintrc-node.json"
75
}

Diff for: ‎Gruntfile.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,21 @@ module.exports = function( grunt ) {
203203

204204
grunt.registerTask( "lint", [
205205
"jsonlint",
206-
runIfNewNode( "eslint" )
206+
207+
// Running the full eslint task without breaking it down to targets
208+
// would run the dist target first which would point to errors in the built
209+
// file, making it harder to fix them. We want to check the built file only
210+
// if we already know the source files pass the linter.
211+
runIfNewNode( "eslint:dev" ),
212+
runIfNewNode( "eslint:dist" )
207213
] );
208214

209215
grunt.registerTask( "lint:newer", [
210216
"newer:jsonlint",
211-
runIfNewNode( "newer:eslint" )
217+
218+
// Don't replace it with just the task; see the above comment.
219+
runIfNewNode( "newer:eslint:dev" ),
220+
runIfNewNode( "newer:eslint:dist" )
212221
] );
213222

214223
grunt.registerTask( "test:fast", runIfNewNode( "node_smoke_tests" ) );

Diff for: ‎dist/.eslintrc.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2-
"extends": "../src/.eslintrc.json",
2+
"root": true,
3+
4+
"extends": "../.eslintrc-browser.json",
5+
36
"rules": {
47
// That is okay for the built version
58
"no-multiple-empty-lines": "off",

Diff for: ‎src/.eslintrc.json

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
{
2-
// Support: IE <=9 only, Android <=4.0 only
3-
// The above browsers are failing a lot of tests in the ES5
4-
// test suite at http://test262.ecmascript.org.
5-
"parserOptions": {
6-
"ecmaVersion": 3
7-
},
8-
"globals": {
9-
"window": true,
10-
"jQuery": true,
11-
"define": true,
12-
"module": true,
13-
"noGlobal": true
14-
},
15-
"rules": {
16-
"strict": ["error", "function"]
17-
}
2+
"root": true,
3+
4+
"extends": "../.eslintrc-browser.json"
185
}

Diff for: ‎test/.eslintrc.json

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2+
"root": true,
3+
4+
"extends": "../.eslintrc-browser.json",
5+
26
"env": {
7+
8+
// In source the browser env is not enabled but unit tests rely on them
9+
// too much and we don't run them in non-browser environments anyway.
310
"browser": true
411
},
5-
// Support: IE <=9 only, Android <=4.0 only
6-
// The above browsers are failing a lot of tests in the ES5
7-
// test suite at http://test262.ecmascript.org.
8-
"parserOptions": {
9-
"ecmaVersion": 3
10-
},
12+
1113
"globals": {
1214
"require": false,
1315
"define": false,
@@ -41,17 +43,19 @@
4143
"baseURL": true,
4244
"externalHost": true
4345
},
46+
4447
"rules": {
4548
// See https://github.com/eslint/eslint/issues/2342
4649
"no-unused-vars": "off",
4750

48-
// Too much errors
51+
// Too many errors
4952
"max-len": "off",
5053
"brace-style": "off",
5154
"key-spacing": "off",
5255
"camelcase": "off",
56+
"strict": "off",
5357

54-
// Not really too much - waiting autofix features for these rules
58+
// Not really too many - waiting for autofix features for these rules
5559
"lines-around-comment": "off",
5660
"dot-notation": "off"
5761
}

Diff for: ‎test/node_smoke_tests/.eslintrc.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
2+
"root": true,
3+
4+
"extends": "../../.eslintrc-node.json",
5+
6+
"parserOptions": {
7+
"ecmaVersion": 2015
8+
},
9+
210
"env": {
311
"es6": true
4-
},
5-
"extends" : "../../.eslintrc.json",
6-
"root": true
12+
}
713
}

Diff for: ‎test/promises_aplus_adapters/.eslintrc.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"extends": "../../.eslintrc.json",
3-
"root": true
2+
"root": true,
3+
4+
"extends": "../../.eslintrc-node.json"
45
}

0 commit comments

Comments
 (0)