Skip to content

Commit 79855cb

Browse files
committed
Added eslint tasks to build (both) and travis step (grunt only)
deleted jslintrc file Addresses #274
1 parent 657ca99 commit 79855cb

File tree

6 files changed

+28
-52
lines changed

6 files changed

+28
-52
lines changed

.jslintrc

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

Gruntfile.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ module.exports = function (grunt) {
138138
}
139139
}
140140
},
141+
eslint: {
142+
options: {
143+
configFile: './.eslintrc'
144+
},
145+
target: ['./builder/*']
146+
},
141147
bsReload: {
142148
css: path.resolve(paths().public.root + '**/*.css')
143149
}
@@ -152,10 +158,10 @@ module.exports = function (grunt) {
152158
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);
153159

154160
//travis CI task
155-
grunt.registerTask('travis', ['nodeunit', 'patternlab']);
161+
grunt.registerTask('travis', ['nodeunit', 'eslint', 'patternlab']);
156162

157163
grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);
158164

159-
grunt.registerTask('build', ['nodeunit', 'concat']);
165+
grunt.registerTask('build', ['nodeunit', 'eslint', 'concat']);
160166

161167
};

builder/pattern_assembler.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*
99
*/
1010

11-
1211
"use strict";
1312

1413
var pattern_assembler = function () {
@@ -78,6 +77,12 @@ var pattern_assembler = function () {
7877
}
7978
}
8079

80+
//http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
81+
function shuffle(o) {
82+
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
83+
return o;
84+
}
85+
8186
function buildListItems(container) {
8287
//combine all list items into one structure
8388
var list = [];
@@ -297,8 +302,7 @@ var pattern_assembler = function () {
297302
}
298303

299304
function mergeData(obj1, obj2) {
300-
/*eslint-disable guard-for-in, no-param-reassign*/
301-
if (typeof obj2 === 'undefined') {
305+
if (typeof obj2 === 'undefined') {
302306
obj2 = {};
303307
}
304308
for (var p in obj1) {
@@ -326,13 +330,6 @@ var pattern_assembler = function () {
326330
return obj2;
327331
}
328332

329-
//http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
330-
function shuffle(o) {
331-
/*eslint-disable curly*/
332-
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
333-
return o;
334-
}
335-
336333
function parseDataLinksHelper(patternlab, obj, key) {
337334
var linkRE, dataObjAsString, linkMatches, expandedLink;
338335

gulpfile.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var pkg = require('./package.json'),
99
strip_banner = require('gulp-strip-banner'),
1010
header = require('gulp-header'),
1111
nodeunit = require('gulp-nodeunit'),
12+
eslint = require('gulp-eslint'),
1213
browserSync = require('browser-sync').create();
1314

1415
require('gulp-load')(gulp);
@@ -151,6 +152,14 @@ gulp.task('connect', ['lab'], function () {
151152

152153
});
153154

155+
//lint
156+
gulp.task('eslint', function () {
157+
return gulp.src(['./builder/*.js', '!node_modules/**'])
158+
.pipe(eslint())
159+
.pipe(eslint.format())
160+
.pipe(eslint.failAfterError());
161+
});
162+
154163
//unit test
155164
gulp.task('nodeunit', function () {
156165
return gulp.src('./test/**/*_tests.js')
@@ -170,7 +179,7 @@ gulp.task('prelab', ['clean', 'assets']);
170179
gulp.task('lab', ['prelab', 'patternlab'], function (cb) { cb(); });
171180
gulp.task('patterns', ['patternlab:only_patterns']);
172181
gulp.task('serve', ['lab', 'connect']);
173-
gulp.task('travis', ['lab', 'nodeunit']);
182+
gulp.task('build', ['eslint', 'nodeunit', 'banner']);
174183

175184
gulp.task('version', ['patternlab:version']);
176185
gulp.task('help', ['patternlab:help']);

package.gulp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
},
1414
"devDependencies": {
1515
"browser-sync": "^2.11.1",
16-
"eslint": "^2.2.0",
1716
"gulp": "^3.9.0",
1817
"gulp-connect": "^2.3.1",
1918
"gulp-copy": "0.0.2",
19+
"gulp-eslint": "^2.0.0",
2020
"gulp-header": "^1.7.1",
2121
"gulp-load": "^0.1.1",
2222
"gulp-nodeunit": "0.0.5",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
},
1414
"devDependencies": {
1515
"bs-html-injector": "^3.0.0",
16-
"eslint": "^2.2.0",
1716
"grunt": "~0.4.5",
1817
"grunt-browser-sync": "^2.2.0",
1918
"grunt-contrib-concat": "^0.5.1",
2019
"grunt-contrib-copy": "^0.8.2",
2120
"grunt-contrib-nodeunit": "^0.4.1",
22-
"grunt-contrib-watch": "^0.6.1"
21+
"grunt-contrib-watch": "^0.6.1",
22+
"grunt-eslint": "^18.0.0"
2323
},
2424
"keywords": [
2525
"Pattern Lab",

0 commit comments

Comments
 (0)