blob: 1aeb44401f070f404083037cd266e8df253440ca [file] [log] [blame]
Steven Burrows1c2a9682017-07-14 16:52:46 +01001import gulp from 'gulp';
2import eslint from 'gulp-eslint';
3import gulpIf from 'gulp-if';
4import path from 'path';
5
6const files = [
7 '../../web/gui/src/main/webapp/app/**/*.js'
8];
9
Steven Burrows202034f2017-08-11 12:08:01 +010010console.log(eslint().version);
11
Steven Burrows1c2a9682017-07-14 16:52:46 +010012function isFixed(file) {
13 // Has ESLint fixed the file contents?
14 return file.eslint != null && file.eslint.fixed;
15}
16
17const lint = () => {
18 return gulp.src(files)
19 .pipe(eslint({
20 configFile: path.join(__dirname, 'esconfig.json'),
21 useEslintrc: false,
22 // Automatically fix trivial issues
23 // fix: true,
24 }))
25 .pipe(eslint.format())
26 .pipe(gulpIf(isFixed,
27 gulp.dest('../../web/gui/src/main/webapp/app')
28 ));
29};
30
31const tasks = () => {
32 gulp.task('lint', () => lint());
33};
34
35export default tasks();