Skip to content

Commit 75dea5c

Browse files
author
CM Lubinski
committed
Add eslint using the airbnb config.
In an effort to make the JS consistent, this adds an ESLint gulp task. ESLint is *very* configurable, and has no defaults. Instead, this reaches for airbnb's legacy config (which covers ES5), which is one of the most popular configurations. As a last step, it turns off all of the rules which currently fail. We can turn them on piecemeal, or override the airbnb style to use a different format. Rules to prioritize (as they likely indicate bugs): * "array-callback-return": "off", * "eqeqeq": "off", * "guard-for-in": "off", * "no-inner-declarations": "off", * "no-loop-func": "off", * "no-mixed-operators": "off", * "no-undef": "off", * "no-use-before-define": "off", * "one-var": "off",
1 parent 99815f7 commit 75dea5c

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.eslintrc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"extends": "airbnb-base/legacy",
3+
"globals": {
4+
"$": true
5+
},
6+
"rules": {
7+
"array-callback-return": "off",
8+
"brace-style": "off",
9+
"camelcase": "off",
10+
"comma-dangle": "off",
11+
"consistent-return": "off",
12+
"dot-notation": "off",
13+
"eqeqeq": "off",
14+
"func-names": "off",
15+
"guard-for-in": "off",
16+
"indent": "off",
17+
"keyword-spacing": "off",
18+
"no-console": "off",
19+
"no-inner-declarations": "off",
20+
"no-loop-func": "off",
21+
"no-mixed-operators": "off",
22+
"no-multi-assign": "off",
23+
"no-param-reassign": "off",
24+
"no-redeclare": "off",
25+
"no-restricted-syntax": "off",
26+
"no-shadow": "off",
27+
"no-undef": "off",
28+
"no-underscore-dangle": "off",
29+
"no-unused-vars": "off",
30+
"no-use-before-define": "off",
31+
"object-curly-spacing": "off",
32+
"one-var": "off",
33+
"padded-blocks": "off",
34+
"quote-props": "off",
35+
"quotes": "off",
36+
"semi": "off",
37+
"space-before-function-paren": "off",
38+
"space-unary-ops": "off",
39+
"spaced-comment": "off",
40+
"vars-on-top": "off",
41+
}
42+
}

gulpfile.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var gulp = require('gulp'),
1212
vinyl_buffer = require('vinyl-buffer'),
1313
es = require('event-stream'),
1414
path = require('path'),
15+
eslint = require('gulp-eslint'),
1516
pkg_config = require('./package.json');
1617

1718
// Applications with primary static sources. We define these here to avoid
@@ -254,4 +255,15 @@ gulp.task('dev', function (done) {
254255
}));
255256
});
256257

258+
gulp.task('lint', function (done) {
259+
var paths = Object.keys(sources).map(function(application) {
260+
return path.join(pkg_config.name, application, 'static-src', '**', '*.js');
261+
});
262+
return gulp
263+
.src(paths)
264+
.pipe(eslint())
265+
.pipe(eslint.format())
266+
.pipe(eslint.failAfterError());
267+
});
268+
257269
gulp.task('default', ['build']);

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
"bower-resolve": "^2.2.1",
1212
"browserify": "*",
1313
"debowerify": "git+https://github.com/agjohnson/debowerify.git#8c6b9a7",
14+
"eslint-config-airbnb-base": "^11.2.0",
15+
"eslint-plugin-import": "^2.2.0",
1416
"event-stream": "^3.3.1",
1517
"gulp": "*",
18+
"gulp-eslint": "^3.0.1",
1619
"gulp-less": "^3.0.3",
1720
"gulp-rename": "^1.2.2",
1821
"gulp-run": "^1.6.6",

0 commit comments

Comments
 (0)