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