Add eslint using the airbnb config. (#2905)
* 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", * Lint frontend in Travis. This adds an ESLint step to the CI service so we prevent unlinted code from making its way in. * Create an ESLint tox env. By adding a tox env for eslint, we allow users to run it locally as part of tox runs. Thanks for the suggestion @ericholscher! * Fix tox call to gulp lint taskgthank-master
parent
64854e4af9
commit
9e07061730
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"extends": "airbnb-base/legacy",
|
||||
"globals": {
|
||||
"$": true
|
||||
},
|
||||
"rules": {
|
||||
"array-callback-return": "off",
|
||||
"brace-style": "off",
|
||||
"camelcase": "off",
|
||||
"comma-dangle": "off",
|
||||
"consistent-return": "off",
|
||||
"dot-notation": "off",
|
||||
"eqeqeq": "off",
|
||||
"func-names": "off",
|
||||
"guard-for-in": "off",
|
||||
"indent": "off",
|
||||
"keyword-spacing": "off",
|
||||
"no-console": "off",
|
||||
"no-inner-declarations": "off",
|
||||
"no-loop-func": "off",
|
||||
"no-mixed-operators": "off",
|
||||
"no-multi-assign": "off",
|
||||
"no-param-reassign": "off",
|
||||
"no-redeclare": "off",
|
||||
"no-restricted-syntax": "off",
|
||||
"no-shadow": "off",
|
||||
"no-undef": "off",
|
||||
"no-underscore-dangle": "off",
|
||||
"no-unused-vars": "off",
|
||||
"no-use-before-define": "off",
|
||||
"object-curly-spacing": "off",
|
||||
"one-var": "off",
|
||||
"padded-blocks": "off",
|
||||
"quote-props": "off",
|
||||
"quotes": "off",
|
||||
"semi": "off",
|
||||
"space-before-function-paren": "off",
|
||||
"space-unary-ops": "off",
|
||||
"spaced-comment": "off",
|
||||
"vars-on-top": "off",
|
||||
}
|
||||
}
|
|
@ -6,11 +6,19 @@ env:
|
|||
- TOX_ENV=py27
|
||||
- TOX_ENV=docs
|
||||
- TOX_ENV=lint
|
||||
- TOX_ENV=eslint
|
||||
cache:
|
||||
directories:
|
||||
- ~/.cache/pip
|
||||
- ~/.nvm/nvm.sh
|
||||
install:
|
||||
- pip install tox
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
|
||||
- source ~/.nvm/nvm.sh
|
||||
- nvm install --lts
|
||||
- nvm use --lts
|
||||
- npm install
|
||||
- bower install
|
||||
script:
|
||||
- tox -e $TOX_ENV
|
||||
notifications:
|
||||
|
|
12
gulpfile.js
12
gulpfile.js
|
@ -12,6 +12,7 @@ var gulp = require('gulp'),
|
|||
vinyl_buffer = require('vinyl-buffer'),
|
||||
es = require('event-stream'),
|
||||
path = require('path'),
|
||||
eslint = require('gulp-eslint'),
|
||||
pkg_config = require('./package.json');
|
||||
|
||||
// Applications with primary static sources. We define these here to avoid
|
||||
|
@ -254,4 +255,15 @@ gulp.task('dev', function (done) {
|
|||
}));
|
||||
});
|
||||
|
||||
gulp.task('lint', function (done) {
|
||||
var paths = Object.keys(sources).map(function(application) {
|
||||
return path.join(pkg_config.name, application, 'static-src', '**', '*.js');
|
||||
});
|
||||
return gulp
|
||||
.src(paths)
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
gulp.task('default', ['build']);
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
"bower-resolve": "^2.2.1",
|
||||
"browserify": "*",
|
||||
"debowerify": "git+https://github.com/agjohnson/debowerify.git#8c6b9a7",
|
||||
"eslint-config-airbnb-base": "^11.2.0",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"event-stream": "^3.3.1",
|
||||
"gulp": "*",
|
||||
"gulp-eslint": "^3.0.1",
|
||||
"gulp-less": "^3.0.3",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-run": "^1.6.6",
|
||||
|
|
Loading…
Reference in New Issue