Closed DerekFoulk closed 8 years ago
How are you configuring gulp-jshint? I don't see it in the portion of your Gulpfile that you shared.
@spalger - So sorry, I grabbed the wrong task... Here is my JSHint task:
gulp.task('jshint', function() {
return gulp.src([
dir.js + '/**/*.js'
])
.pipe( plugins.jshint() )
.pipe( plugins.jshint.reporter('jshint-stylish') )
.pipe( plugins.notify( function (file) {
if ( file.jshint.success ) {
// Don't show something if success
return false;
}
var errors = file.jshint.results.map( function (data) {
if ( data.error ) {
return "(Line " + data.error.line + ' : Col ' + data.error.character + ') ' + data.error.reason;
}
}).join('\n');
return file.relative + " (" + file.jshint.results.length + " errors)\n" + errors;
}))
.pipe( plugins.jshint.reporter('fail') );
});
Welp, I'm seeing the same behavior as you originally reported. I'm closing this though because this the also what the CLI does -- my ultimate benchmark is parity with the features of the jshint cli.
Sorry it didn't work as you would expect, but the file you linked must not be the shipping defaults. The comment at the top makes it sound like that, but maybe they just mean it's the default for http://jshint.com/?
reproduction: https://github.com/spalger/reproduce-issues/tree/master/gulp-jshint-141
If the defaults listed in the sample file may not be the actual defaults, then that would explain this behavior absolutely! Maybe I was just looking at this the wrong way. Thank you for your time. If I come across any further issues with this, I will report the issue on JSHint's tracker instead. Thank you for the quick responses and assistance!
I am using JSHint 2.9.2 (installed globally via NPM) with gulp-jshint 2.0.0.
Here is the relevant task from my Gulpfile.js:
Here is my .jshintrc file:
Here is the JS file to be linted:
What should happen:
JSHint should detect 2 errors in the code:
What actually happens:
No errors are detected, and the gulp build finishes without any JSHint notifications.
How I remedied the issue:
1) Copy the entire example .jshintrc file provided by JSHint 2) Paste those options into a .jshintrc file in my repo's root 3) Change
"jquery": false
to"jquery": true
4) Rungulp
againThe errors in the file are detected after adding all of the default rules to my .jshintrc file.
Basically, it seems that the default options are not used by JSHint unless they are explicitly specified inline or in a .jshintrc file.
Note: I have not confirmed that all options are being overlooked, or if it is just an option that is necessary to detect the errors in my file.