Build: Switch from jscs+jshint to eslint

This commit is contained in:
Oleg Gaidarenko 2016-05-10 12:06:37 +03:00
parent 019c8f1f41
commit f80ae67c53
14 changed files with 261 additions and 160 deletions

12
.eslintignore Normal file
View File

@ -0,0 +1,12 @@
external
test/data/jquery-1.9.1.js
test/data/badcall.js
test/data/badjson.js
test/data/json_obj.js
test/data/readywaitasset.js
test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js
test/node_smoke_tests/lib/ensure_iterability.js
node_modules
dist

145
.eslintrc Normal file
View File

@ -0,0 +1,145 @@
{
"env": {},
"globals": {},
"rules": {
"no-cond-assign": [
"error",
"except-parens"
],
"curly": [
"error",
"all"
],
"object-curly-spacing": [
"error",
"always"
],
"computed-property-spacing": [
"error",
"always"
],
"array-bracket-spacing": [
"error",
"always"
],
"eqeqeq": [
"error",
"smart"
],
// Shows errors where jshint wouldn't (see jshint "expr" rule)
// clarifing this with eslint team
// "no-unused-expressions": "error",
"wrap-iife": [
"error",
"inside"
],
"no-caller": "error",
"quotes": [
"error",
"double",
"avoid-escape"
],
"no-undef": "error",
"no-unused-vars": "error",
"operator-linebreak": [
"error",
"after"
],
"comma-style": [
"error",
"last"
],
"camelcase": [
"error",
{
"properties": "never"
}
],
"dot-notation": [
"error",
{
"allowPattern": "^[a-z]+(_[a-z]+)+$"
}
],
"max-len": [
"error",
{
"code": 100,
"ignoreComments": true
}
],
"no-mixed-spaces-and-tabs": "error",
"no-trailing-spaces": "error",
"no-multi-str": "error",
"comma-dangle": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"space-before-blocks": [
"error",
"always"
],
"space-in-parens": [
"error",
"always"
],
"keyword-spacing": [
2
],
"semi": [
"error",
"always"
],
"semi-spacing": [
"error",
{
// Because of the `for ( ; ...)` requirement
// "before": true,
"after": true
}
],
"space-infix-ops": "error",
"eol-last": "error",
"lines-around-comment": [
"error",
{
"beforeLineComment": true
}
],
"linebreak-style": [
"error",
"unix"
],
"no-with": "error",
"brace-style": "error",
"space-before-function-paren": [
"error",
"never"
],
"no-loop-func": "error",
"no-spaced-func": "error",
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true
}
],
"space-unary-ops": [
"error",
{
"words": false,
"nonwords": false
}
],
"no-multiple-empty-lines": 2
}
}

10
.jscsrc
View File

@ -1,10 +0,0 @@
{
"preset": "jquery",
// remove after https://github.com/jscs-dev/node-jscs/issues/1685
// and https://github.com/jscs-dev/node-jscs/issues/1686
"requireCapitalizedComments": null,
"excludeFiles": [ "external",
"test/node_smoke_tests/lib/ensure_iterability.js", "node_modules" ]
}

View File

@ -1,14 +0,0 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"undef": true,
"unused": true,
"node": true
}

View File

@ -1,5 +1,5 @@
.jshintignore .eslintignore
.jshintrc .eslintrc
/.editorconfig /.editorconfig
/.gitattributes /.gitattributes

View File

@ -14,7 +14,6 @@ module.exports = function( grunt ) {
var fs = require( "fs" ), var fs = require( "fs" ),
gzip = require( "gzip-js" ), gzip = require( "gzip-js" ),
srcHintOptions = readOptionalJSON( "src/.jshintrc" ),
// Skip jsdom-related tests in Node.js 0.10 & 0.12 // Skip jsdom-related tests in Node.js 0.10 & 0.12
runJsdomTests = !/^v0/.test( process.version ); runJsdomTests = !/^v0/.test( process.version );
@ -103,34 +102,14 @@ module.exports = function( grunt ) {
src: [ "package.json" ] src: [ "package.json" ]
} }
}, },
jshint: { eslint: {
all: { options: {
src: [
"src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js"
],
options: {
jshintrc: true
}
},
dist: {
src: "dist/jquery.js",
options: srcHintOptions
}
},
jscs: {
src: "src",
gruntfile: "Gruntfile.js",
// Check parts of tests that pass // See https://github.com/sindresorhus/grunt-eslint/issues/119
test: [ quiet: true
"test/data/testrunner.js", },
"test/unit/animation.js", all: ".",
"test/unit/basic.js", dev: [ "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" ]
"test/unit/support.js",
"test/unit/tween.js",
"test/unit/wrap.js"
],
build: "build"
}, },
testswarm: { testswarm: {
tests: [ tests: [
@ -164,7 +143,7 @@ module.exports = function( grunt ) {
] ]
}, },
watch: { watch: {
files: [ "<%= jshint.all.src %>" ], files: [ "<%= eslint.dev %>" ],
tasks: [ "dev" ] tasks: [ "dev" ]
}, },
uglify: { uglify: {
@ -201,7 +180,7 @@ module.exports = function( grunt ) {
// Integrate jQuery specific tasks // Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" ); grunt.loadTasks( "build/tasks" );
grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] ); grunt.registerTask( "lint", [ "jsonlint" ] );
// Don't run Node-related tests in Node.js < 1.0.0 as they require an old // Don't run Node-related tests in Node.js < 1.0.0 as they require an old
// jsdom version that needs compiling, making it harder for people to compile // jsdom version that needs compiling, making it harder for people to compile
@ -213,9 +192,15 @@ module.exports = function( grunt ) {
) ); ) );
// Short list as a high frequency watch task // Short list as a high frequency watch task
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] ); grunt.registerTask( "dev", [
"build:*:*",
"uglify",
"remove_map_comment",
"dist:*"
]
);
grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] ); grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );
grunt.registerTask( "precommit_lint", [ "newer:jsonlint", "newer:jshint:all", "newer:jscs" ] ); grunt.registerTask( "precommit_lint", [ "newer:jsonlint" ] );
}; };

7
build/.eslintrc Normal file
View File

@ -0,0 +1,7 @@
{
"env": {
"node": true
},
"extends": "../.eslintrc",
"root": true
}

View File

@ -33,11 +33,10 @@
"grunt-babel": "6.0.0", "grunt-babel": "6.0.0",
"grunt-cli": "1.2.0", "grunt-cli": "1.2.0",
"grunt-compare-size": "0.4.2", "grunt-compare-size": "0.4.2",
"grunt-contrib-jshint": "1.0.0",
"grunt-contrib-uglify": "1.0.1", "grunt-contrib-uglify": "1.0.1",
"grunt-contrib-watch": "1.0.0", "grunt-contrib-watch": "1.0.0",
"grunt-eslint": "18.1.0",
"grunt-git-authors": "3.2.0", "grunt-git-authors": "3.2.0",
"grunt-jscs": "2.8.0",
"grunt-jsonlint": "1.0.7", "grunt-jsonlint": "1.0.7",
"grunt-newer": "1.2.0", "grunt-newer": "1.2.0",
"grunt-npmcopy": "0.1.0", "grunt-npmcopy": "0.1.0",

15
src/.eslintrc Normal file
View File

@ -0,0 +1,15 @@
{
"env": {
"browser"
},
"extends": "../.eslintrc",
"root": true,
"globals": {
"window": true,
"JSON": false,
"jQuery": true,
"define": true,
"module": true,
"noGlobal": true
}
}

View File

@ -1,30 +0,0 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"strict": true,
"undef": true,
"unused": true,
"sub": 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.
"es3": true,
"globals": {
"window": true,
"JSON": false,
"jQuery": true,
"define": true,
"module": true,
"noGlobal": true
}
}

55
test/.eslintrc Normal file
View File

@ -0,0 +1,55 @@
{
"env": {
"browser": true
},
"extends": "../.eslintrc",
"root": true,
"globals": {
"require": false,
"define": false,
"DOMParser": false,
"JSON": false,
"Promise": false,
"Symbol": false,
"QUnit": false,
"ajaxTest": false,
"testIframe": false,
"testIframeWithCallback": false,
"iframeCallback": true,
"createDashboardXML": false,
"createXMLFragment": false,
"moduleTeardown": false,
"testFoo": false,
"url": false,
"t": false,
"q": false,
"jQuery": true,
"sinon": true,
"amdDefined": true,
"fireNative": true,
"Globals": true,
"hasPHP": true,
"isLocal": true,
"supportjQuery": true,
"originaljQuery": true,
"$": true,
"original$": true,
"baseURL": true,
"externalHost": true
},
"rules": {
// See https://github.com/eslint/eslint/issues/6125
"no-unused-vars": "off",
// Too much errors
"max-len": "off",
"brace-style": "off",
"key-spacing": "off",
"camelcase": "off",
"dot-notaion": "off",
// Not a lot really too much, but waiting for autofix for these rules
"lines-around-comment": "off",
"dot-notation": "off"
}
}

View File

@ -1,56 +0,0 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"undef": true,
"unused": true,
"es3": true,
"evil": true,
"sub": true,
"browser": true,
"devel": true,
"wsh": true,
"globals": {
"require": false,
"define": false,
"DOMParser": false,
"JSON": false,
"Promise": false,
"Symbol": false,
"QUnit": false,
"ajaxTest": false,
"testIframe": false,
"testIframeWithCallback": false,
"iframeCallback": true,
"createDashboardXML": false,
"createXMLFragment": false,
"moduleTeardown": false,
"testFoo": false,
"url": false,
"t": false,
"q": false,
"jQuery": true,
"sinon": true,
"amdDefined": true,
"fireNative": true,
"Globals": true,
"hasPHP": true,
"isLocal": true,
"supportjQuery": true,
"originaljQuery": true,
"$": true,
"original$": true,
"baseURL": true,
"externalHost": true
}
}

View File

@ -0,0 +1,7 @@
{
"env": {
"node": true
},
"extends": "../.eslintrc",
"root": true
}

View File

@ -1,14 +0,0 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"undef": true,
"unused": true,
"node": true
}