I'm trying to install the Airbnb JavaScript style guide into my environment. I'm using gulp to show linting errors as I save my .js files but it does not show it. If I do 'eslint main.js' it shows me the errors.
Is there any way I can show it through gulp when I execute 'gulp'?
Here are my config files:
var lint = require('gulp-eslint'); //Lint JS files, including JSX
var config = {
port: 9005,
devBaseUrl: 'http://localhost',
paths: {
html: './src/*.html',
js: './src/**/.js',
css: [
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/bootstrap/dist/css/bootstrap-theme.min.css'
],
dist: './dist',
mainJs: './src/main.js'
}
};
...
gulp.task('lint', function () {
return gulp.src(config.paths.js)
.pipe(lint())
.pipe(lint.format())
.pipe(lint.failAfterError());
});
gulp.task('watch', function () {
gulp.watch(config.paths.html, ['html']);
gulp.watch(config.paths.js, ['js', 'lint']);
gulp.watch(config.paths.css, ['css']);
});
gulp.task('default', ['html', 'js', 'css', 'lint', 'open', 'watch']);
my main.js file:
test = 1;
var App = console.log('Testing Browserify');
module.exports = App;
and here is what I see when I run 'gulp' and also when I run 'eslint main.js'. Errors should show on the terminal to the right, but it does not show any linting errors.
Have you tried setting your eslint configuration file on lint call?
gulp.task('lint', function () {
return gulp.src(config.paths.js)
.pipe(lint({
// Load a specific ESLint config
configFile: 'eslintConfig.json'
}
))
.pipe(lint.format())
.pipe(lint.failAfterError());
});
From: https://github.com/adametry/gulp-eslint/blob/master/example/config.js