habitica/tasks/gulp-eslint.js

64 lines
1.6 KiB
JavaScript
Raw Normal View History

import gulp from 'gulp';
import eslint from 'gulp-eslint';
2015-11-20 13:56:59 +00:00
const SERVER_FILES = [
'./website/src/**/api-v3/**/*.js',
// Comment these out in develop, uncomment them in api-v3
// './website/src/models/user.js',
// './website/src/server.js'
];
const COMMON_FILES = [
'./common/script/**/*.js',
// @TODO remove these negations as the files are converted over.
'!./common/script/index.js',
'!./common/script/content/index.js',
'!./common/script/src/**/*.js',
'!./common/script/public/**/*.js',
];
const TEST_FILES = [
'./test/**/*.js',
// @TODO remove these negations as the test files are cleaned up.
'!./test/api-legacy/**/*',
'!./test/api/**/*',
'!./test/common/simulations/**/*',
'!./test/content/**/*',
'!./test/e2e/**/*',
'!./test/server_side/**/*',
'!./test/spec/**/*',
];
let linter = (src, options) => {
return gulp
.src(src)
.pipe(eslint(options))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
};
2015-11-20 13:56:59 +00:00
2015-11-14 13:40:05 +00:00
// TODO lint client
// TDOO separate linting cong between
// TODO lint gulp tasks, tests, ...?
// TODO what about prefer-const rule?
// TODO remove estraverse dependency once https://github.com/adametry/gulp-eslint/issues/117 sorted out
gulp.task('lint:server', () => {
2015-11-20 13:56:59 +00:00
return linter(SERVER_FILES);
});
2015-11-14 13:49:48 +00:00
gulp.task('lint:common', () => {
2015-11-20 13:56:59 +00:00
return linter(COMMON_FILES);
2015-11-14 13:49:48 +00:00
});
2015-11-18 05:14:49 +00:00
gulp.task('lint:tests', () => {
return linter(TEST_FILES);
2015-11-18 05:14:49 +00:00
});
2015-11-20 02:27:39 +00:00
gulp.task('lint', ['lint:server', 'lint:common', 'lint:tests']);
2015-11-18 23:23:33 +00:00
gulp.task('lint:watch', () => {
gulp.watch([
2015-11-20 13:56:59 +00:00
SERVER_FILES,
COMMON_FILES,
TEST_FILES,
2015-11-18 23:23:33 +00:00
], ['lint']);
});