Install required NPM modules in the directory
npm install gulp jshint gulp-jshint jshint-stylish gulp-watch
Create your gulpfile.js
and paste in the following code
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var watch = require('gulp-watch');
gulp.task('default', ['lint', 'watch']);
gulp.task('watch', function() {
gulp.watch('./javascripts/**/*.js', ['lint']);
});
gulp.task('lint', function() {
return gulp.src('./javascripts/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
Set some options for jshint. Create a .jshintrc
in your directory and paste in the following configuration object.
{
"predef": [ "document", "jQuery", "$", "console" ],
"esversion": 6,
"globalstrict": true
}