ft/aurelia_project/tasks/lint-js.js
2017-06-09 09:09:06 +01:00

46 lines
1.2 KiB
JavaScript

import gulp from 'gulp';
import project from '../aurelia.json';
import eslint from 'gulp-eslint';
import {CLIOptions} from 'aurelia-cli';
// linting configuration in is .eslintrc.json file in project root folder
function lintJsSrc() {
if (CLIOptions.hasFlag('watch')) {
return gulp.src(project.jsLinter.source)
.pipe(eslint())
.pipe(eslint.format());
}
return gulp.src(project.jsLinter.source)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
// linting tests is les strict - console.log and
function lintJsTests() {
if (CLIOptions.hasFlag('watch')) {
return gulp.src(project.jsLinter.testSource)
.pipe(eslint({
'rules': {
'no-console': ['warn'],
'no-unused-vars': ['warn'],
'quotes': ['off', 'single']
}
}))
.pipe(eslint.format());
}
return gulp.src(project.jsLinter.testSource)
.pipe(eslint({
'rules': {
'no-console': ['warn'],
'no-unused-vars': ['warn'],
'quotes': ['off', 'single']
}
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
export default gulp.parallel(lintJsSrc, lintJsTests);