I have a project that shows an error when linting without gulp, but fails to show the same error when linting via gulp-eslint.
gulpfile.js
const gulp = require('gulp');
const inject = require('gulp-inject'); // Should error since this is never used
const eslint = require('gulp-eslint');
// Common paths
const paths = {
index: './index.html',
dist: './dist',
js: '**/*.js',
nodeModules: 'nodeModules/**'
};
gulp.task('default', ['lint'], function() {
// place code for your default task here
});
gulp.task('lint', function() {
return gulp.src([paths.js, '!' + paths.nodeModules])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
.eslintrc.json
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"globals": {
"require": true
},
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
"strict": ["error", "safe"]
}
}
eslint directly works, but not via gulp task
$ eslint gulpfile.js
gulpfile.js
3:7 error 'inject' is assigned a value but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)
$ gulp lint
[12:13:29] Using gulpfile ~/Sites/myproject/gulpfile.js
[12:13:29] Starting 'lint'...
[12:13:29] Finished 'lint' after 35 ms
project structure
- eslintrc.json
- gulpfile.js
Why does my gulp task not lint properly?
EDIT
Seems that if I change to paths.js below, it lints all files in any subdir
const paths = {
js: '*/*.js',
};
If i change to paths.js below, it lints all files in the current dir
const paths = {
js: '*.js',
};
I'm a bit puzzled why **/*.js
doesn't lint anything?