Skip to content

Instantly share code, notes, and snippets.

@JoeShep
Created April 25, 2016 22:14
Show Gist options
  • Save JoeShep/9a7fa0eb163d57bfc344aefe5cfa5bd1 to your computer and use it in GitHub Desktop.
Save JoeShep/9a7fa0eb163d57bfc344aefe5cfa5bd1 to your computer and use it in GitHub Desktop.
Simple Gulp jshint watcher

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment