mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
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).
This commit is contained in:
parent
5d79c64663
commit
cbc8638c38
31
.eslintrc-browser.json
Normal file
31
.eslintrc-browser.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
|
||||||
|
"extends": "jquery",
|
||||||
|
|
||||||
|
// Support: IE <=9 only, Android <=4.0 only
|
||||||
|
// The above browsers are failing a lot of tests in the ES5
|
||||||
|
// test suite at http://test262.ecmascript.org.
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 3
|
||||||
|
},
|
||||||
|
|
||||||
|
// The browser env is not enabled on purpose so that code takes
|
||||||
|
// all browser-only globals from window instead of assuming
|
||||||
|
// they're available as globals. This makes it possible to use
|
||||||
|
// jQuery with tools like jsdom which provide a custom window
|
||||||
|
// implementation.
|
||||||
|
"env": {},
|
||||||
|
|
||||||
|
"globals": {
|
||||||
|
"window": true,
|
||||||
|
"jQuery": true,
|
||||||
|
"define": true,
|
||||||
|
"module": true,
|
||||||
|
"noGlobal": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
"strict": ["error", "function"]
|
||||||
|
}
|
||||||
|
}
|
13
.eslintrc-node.json
Normal file
13
.eslintrc-node.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
|
||||||
|
"extends": "jquery",
|
||||||
|
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 5
|
||||||
|
},
|
||||||
|
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "eslint-config-jquery",
|
|
||||||
"root": true,
|
"root": true,
|
||||||
"env": {
|
|
||||||
"node": true
|
"extends": "./.eslintrc-node.json"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
13
Gruntfile.js
13
Gruntfile.js
@ -203,12 +203,21 @@ module.exports = function( grunt ) {
|
|||||||
|
|
||||||
grunt.registerTask( "lint", [
|
grunt.registerTask( "lint", [
|
||||||
"jsonlint",
|
"jsonlint",
|
||||||
runIfNewNode( "eslint" )
|
|
||||||
|
// Running the full eslint task without breaking it down to targets
|
||||||
|
// would run the dist target first which would point to errors in the built
|
||||||
|
// file, making it harder to fix them. We want to check the built file only
|
||||||
|
// if we already know the source files pass the linter.
|
||||||
|
runIfNewNode( "eslint:dev" ),
|
||||||
|
runIfNewNode( "eslint:dist" )
|
||||||
] );
|
] );
|
||||||
|
|
||||||
grunt.registerTask( "lint:newer", [
|
grunt.registerTask( "lint:newer", [
|
||||||
"newer:jsonlint",
|
"newer:jsonlint",
|
||||||
runIfNewNode( "newer:eslint" )
|
|
||||||
|
// Don't replace it with just the task; see the above comment.
|
||||||
|
runIfNewNode( "newer:eslint:dev" ),
|
||||||
|
runIfNewNode( "newer:eslint:dist" )
|
||||||
] );
|
] );
|
||||||
|
|
||||||
grunt.registerTask( "test:fast", runIfNewNode( "node_smoke_tests" ) );
|
grunt.registerTask( "test:fast", runIfNewNode( "node_smoke_tests" ) );
|
||||||
|
5
dist/.eslintrc.json
vendored
5
dist/.eslintrc.json
vendored
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": "../src/.eslintrc.json",
|
"root": true,
|
||||||
|
|
||||||
|
"extends": "../.eslintrc-browser.json",
|
||||||
|
|
||||||
"rules": {
|
"rules": {
|
||||||
// That is okay for the built version
|
// That is okay for the built version
|
||||||
"no-multiple-empty-lines": "off",
|
"no-multiple-empty-lines": "off",
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
{
|
{
|
||||||
// Support: IE <=9 only, Android <=4.0 only
|
"root": true,
|
||||||
// The above browsers are failing a lot of tests in the ES5
|
|
||||||
// test suite at http://test262.ecmascript.org.
|
"extends": "../.eslintrc-browser.json"
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 3
|
|
||||||
},
|
|
||||||
"globals": {
|
|
||||||
"window": true,
|
|
||||||
"jQuery": true,
|
|
||||||
"define": true,
|
|
||||||
"module": true,
|
|
||||||
"noGlobal": true
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"strict": ["error", "function"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
|
"root": true,
|
||||||
|
|
||||||
|
"extends": "../.eslintrc-browser.json",
|
||||||
|
|
||||||
"env": {
|
"env": {
|
||||||
|
|
||||||
|
// In source the browser env is not enabled but unit tests rely on them
|
||||||
|
// too much and we don't run them in non-browser environments anyway.
|
||||||
"browser": true
|
"browser": true
|
||||||
},
|
},
|
||||||
// Support: IE <=9 only, Android <=4.0 only
|
|
||||||
// The above browsers are failing a lot of tests in the ES5
|
|
||||||
// test suite at http://test262.ecmascript.org.
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 3
|
|
||||||
},
|
|
||||||
"globals": {
|
"globals": {
|
||||||
"require": false,
|
"require": false,
|
||||||
"define": false,
|
"define": false,
|
||||||
@ -41,17 +43,19 @@
|
|||||||
"baseURL": true,
|
"baseURL": true,
|
||||||
"externalHost": true
|
"externalHost": true
|
||||||
},
|
},
|
||||||
|
|
||||||
"rules": {
|
"rules": {
|
||||||
// See https://github.com/eslint/eslint/issues/2342
|
// See https://github.com/eslint/eslint/issues/2342
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
|
|
||||||
// Too much errors
|
// Too many errors
|
||||||
"max-len": "off",
|
"max-len": "off",
|
||||||
"brace-style": "off",
|
"brace-style": "off",
|
||||||
"key-spacing": "off",
|
"key-spacing": "off",
|
||||||
"camelcase": "off",
|
"camelcase": "off",
|
||||||
|
"strict": "off",
|
||||||
|
|
||||||
// Not really too much - waiting autofix features for these rules
|
// Not really too many - waiting for autofix features for these rules
|
||||||
"lines-around-comment": "off",
|
"lines-around-comment": "off",
|
||||||
"dot-notation": "off"
|
"dot-notation": "off"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
|
"root": true,
|
||||||
|
|
||||||
|
"extends": "../../.eslintrc-node.json",
|
||||||
|
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2015
|
||||||
|
},
|
||||||
|
|
||||||
"env": {
|
"env": {
|
||||||
"es6": true
|
"es6": true
|
||||||
},
|
}
|
||||||
"extends" : "../../.eslintrc.json",
|
|
||||||
"root": true
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../.eslintrc.json",
|
"root": true,
|
||||||
"root": true
|
|
||||||
|
"extends": "../../.eslintrc-node.json"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user