SC_Adams
SC_Adams

Reputation: 156

JSHint not running under Gulp on Windows

I am trying to get started with JSHint though Gulp, but am running into a problem. On a windows 7 machine I can run JSHint on a file with a known error and get:

C:\Projects\eBuz Projects\node>jshint bdemo.js
bdemo.js: line 3, col 11, Missing semicolon.
bdemo.js: line 6, col 5, Expected an assignment or function call and instead saw an expression.

2 errors

As expected. But when I use gulp I get no errors. The gulpfile.js is

'use strict';

var gulp = require('gulp');
var jshint = require('gulp-jshint');

gulp.task('js_hint', function () { 
    gulp.src(['C:/Projects/**/bdemo.js']).pipe(jshint());
});

The output is

C:\Projects\eBuz Projects\node>gulp js_hint
[11:13:34] Using gulpfile C:\Projects\eBuz Projects\node\gulpfile.js
[11:13:34] Starting 'js_hint'...
[11:13:34] Finished 'js_hint' after 7.47 ms

I have tried a variety of src paths but with the same results. I have verified glup-jshint is installed.

Thanks for the help

Upvotes: 1

Views: 113

Answers (1)

Appy
Appy

Reputation: 21

What you're missing is piping a gulp-jshint reporter to the jshint process

gulp.task('js_hint', function () { 
  gulp.src(['C:/Projects/**/bdemo.js'])
      .pipe(jshint())
      .pipe(jshint.reporter('default'));   //add this line
});

Now, try running

gulp js_hint

It should work!

Upvotes: 1

Related Questions