Skip to content

Commit f5c2e6e

Browse files
mgolleobalter
authored andcommitted
Build: Switch from JSHint to ESLint with the jquery preset
Also, fix linting violations in the process Closes gh-110
1 parent 9e770b2 commit f5c2e6e

13 files changed

+284
-266
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bower_component/**
2+
external/**
3+
node_modules/**

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": "eslint-config-jquery",
3+
"root": true,
4+
"rules": {
5+
6+
// Increase max-len to 120 for now, there are too many violations and the rule
7+
// is not auto-fixable.
8+
"max-len": [
9+
"error",
10+
{
11+
"code": 150,
12+
"ignoreComments": true
13+
}
14+
]
15+
},
16+
"env": {
17+
"node": true
18+
},
19+
"globals": {
20+
"jQuery": true,
21+
"define": true,
22+
"require": true,
23+
"module": true
24+
}
25+
}

.jshintrc

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

Gruntfile.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/*jshint node: true */
21
module.exports = function( grunt ) {
32

43
"use strict";
54

65
var max = [ "dist/jquery.color.js", "dist/jquery.color.svg-names.js" ],
7-
min = [ "dist/jquery.color.min.js", "dist/jquery.color.svg-names.min.js", "dist/jquery.color.plus-names.min.js"],
6+
min = [ "dist/jquery.color.min.js", "dist/jquery.color.svg-names.min.js", "dist/jquery.color.plus-names.min.js" ],
87
combined = "dist/jquery.color.plus-names.js",
98
minify = {
109
main: {
@@ -33,15 +32,9 @@ minify.svg.files[ min[ 1 ] ] = [ max[ 1 ] ];
3332
minify.combined.files[ min[ 2 ] ] = [ combined ];
3433
concat[ combined ] = [ max[ 0 ], max[ 1 ] ];
3534

36-
grunt.loadNpmTasks( "grunt-bowercopy" );
37-
grunt.loadNpmTasks( "grunt-compare-size" );
38-
grunt.loadNpmTasks( "grunt-contrib-concat" );
39-
grunt.loadNpmTasks( "grunt-contrib-jshint" );
40-
grunt.loadNpmTasks( "grunt-contrib-qunit" );
41-
grunt.loadNpmTasks( "grunt-contrib-uglify" );
42-
grunt.loadNpmTasks( "grunt-git-authors" );
35+
require( "load-grunt-tasks" )( grunt );
4336

44-
grunt.initConfig({
37+
grunt.initConfig( {
4538
pkg: grunt.file.readJSON( "package.json" ),
4639

4740
bowercopy: {
@@ -96,13 +89,22 @@ grunt.initConfig({
9689
}
9790
},
9891

99-
jshint: {
92+
eslint: {
10093
options: {
101-
jshintrc: true
94+
95+
// See https://github.com/sindresorhus/grunt-eslint/issues/119
96+
quiet: true
97+
},
98+
99+
source: {
100+
src: [ "jquery.color.js", "jquery.color.svg-names.js" ]
102101
},
103-
src: [ "jquery.color.js", "jquery.color.svg-names.js" ],
104-
grunt: "Gruntfile.js",
105-
test: "test/unit/**"
102+
grunt: {
103+
src: "Gruntfile.js"
104+
},
105+
test: {
106+
src: "test/unit/**"
107+
}
106108
},
107109

108110
qunit: {
@@ -118,11 +120,11 @@ grunt.initConfig({
118120
"svg-names": [ max[ 1 ], min[ 1 ] ],
119121
"combined": [ combined, min[ 2 ] ]
120122
}
121-
});
123+
} );
122124

123125

124126
function gitDate( fn ) {
125-
grunt.util.spawn({
127+
grunt.util.spawn( {
126128
cmd: "git",
127129
args: [ "log", "-1", "--pretty=format:%ad" ]
128130
}, function( error, result ) {
@@ -132,7 +134,7 @@ function gitDate( fn ) {
132134
}
133135

134136
fn( null, result );
135-
});
137+
} );
136138
}
137139

138140
grunt.registerTask( "max", function() {
@@ -142,7 +144,7 @@ grunt.registerTask( "max", function() {
142144
if ( process.env.COMMIT ) {
143145
version += " " + process.env.COMMIT;
144146
}
145-
gitDate(function( error, date ) {
147+
gitDate( function( error, date ) {
146148
if ( error ) {
147149
return done( false );
148150
}
@@ -154,13 +156,13 @@ grunt.registerTask( "max", function() {
154156
.replace( /@VERSION/g, version )
155157
.replace( /@DATE/g, date );
156158
}
157-
});
158-
});
159+
} );
160+
} );
159161

160162

161163
done();
162-
});
163-
});
164+
} );
165+
} );
164166

165167
grunt.registerTask( "testswarm", function( commit, configFile ) {
166168
var testswarm = require( "testswarm" ),
@@ -173,7 +175,7 @@ grunt.registerTask( "testswarm", function( commit, configFile ) {
173175
.auth( {
174176
id: config.authUsername,
175177
token: config.authToken
176-
})
178+
} )
177179
.addjob(
178180
{
179181
name: "Commit <a href='https://github.com/jquery/jquery-color/commit/" + commit + "'>" + commit.substr( 0, 10 ) + "</a>",
@@ -189,11 +191,11 @@ grunt.registerTask( "testswarm", function( commit, configFile ) {
189191
done( passed );
190192
}
191193
);
192-
});
194+
} );
193195

194196
grunt.registerTask( "manifest", function() {
195197
var pkg = grunt.config( "pkg" );
196-
grunt.file.write( "color.jquery.json", JSON.stringify({
198+
grunt.file.write( "color.jquery.json", JSON.stringify( {
197199
name: "color",
198200
title: pkg.title,
199201
description: pkg.description,
@@ -204,10 +206,10 @@ grunt.registerTask( "manifest", function() {
204206
url: pkg.author.url.replace( "master", pkg.version )
205207
},
206208
maintainers: pkg.maintainers,
207-
licenses: pkg.licenses.map(function( license ) {
209+
licenses: pkg.licenses.map( function( license ) {
208210
license.url = license.url.replace( "master", pkg.version );
209211
return license;
210-
}),
212+
} ),
211213
bugs: pkg.bugs,
212214
homepage: pkg.homepage,
213215
docs: pkg.homepage,
@@ -216,10 +218,10 @@ grunt.registerTask( "manifest", function() {
216218
jquery: ">=1.5"
217219
}
218220
}, null, "\t" ) );
219-
});
221+
} );
220222

221-
grunt.registerTask( "default", [ "jshint", "qunit", "build", "compare_size" ] );
223+
grunt.registerTask( "default", [ "eslint", "qunit", "build", "compare_size" ] );
222224
grunt.registerTask( "build", [ "max", "concat", "uglify" ] );
223-
grunt.registerTask( "ci", [ "jshint", "qunit" ] );
225+
grunt.registerTask( "ci", [ "eslint", "qunit" ] );
224226

225227
};

0 commit comments

Comments
 (0)