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 | 202034f | 2017-08-11 12:08:01 +0100 | [diff] [blame] | 10 | console.log(eslint().version); |
| 11 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 12 | function isFixed(file) { |
| 13 | // Has ESLint fixed the file contents? |
| 14 | return file.eslint != null && file.eslint.fixed; |
| 15 | } |
| 16 | |
| 17 | const 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 | |
| 31 | const tasks = () => { |
| 32 | gulp.task('lint', () => lint()); |
| 33 | }; |
| 34 | |
| 35 | export default tasks(); |