Skip to content

Instantly share code, notes, and snippets.

@thuld
Created March 21, 2014 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thuld/49be503928ed753c1d8d to your computer and use it in GitHub Desktop.
Save thuld/49be503928ed753c1d8d to your computer and use it in GitHub Desktop.
The following code will setup the task that will generate an error report whenever an problem is detected in one of the specified script files:
"use strict";
var gulp = require('gulp');
var gutil = require('gulp-util');
var stylish = require('jshint-stylish');
var jshint = require('gulp-jshint');
gulp.task('lint', function() {
// this will exclude the modules folder
var sourcefiles = [
'./**/*.js',
'!./node_modules/**',
'!gulpfile.js'
];
gulp.src( sourcefiles )
.pipe(jshint( '.jshintrc' ))
// .pipe(jshint.reporter('default'));
.pipe( jshint.reporter(stylish) );
});
gulp.task('watch', function(){
// adds a watch that executes the lint task everytime
// a file is modified
gulp.watch( ['.jshintrc', '*.js', 'lib/*.js'], ['lint'] );
});
// define the default task that is invoked
// when "gulp" is executed on the cmd-line
gulp.task('default', [ 'watch' ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment