Adrian Adrian - 3 months ago 18
Node.js Question

gulp-jslint doesn't include error description in output, says "undefined : undefined" instead

I'm running gulp-jslint and it correctly flags errors, but doesn't include the description of the errors in the output.

Here's gulpfile.js:

var gulp = require('gulp'),
jslint = require('gulp-jslint');

gulp.task('default', ['jslint-server']);

gulp.task('jslint-server', function () {
return gulp.src([ // some example files
'scripts/*.js',
'web-server.js'
])
.pipe(jslint({ node:true, bitwise:true }))
.pipe(jslint.reporter( 'stylish' ));
});


And here's the output:

✓ config.js
✖ ConfigController.js
✖ 6:undefined: undefined
✖ 8:undefined: undefined
✓ FeaturesController.js
✓ web-server.js


It has correctly flagged two errors. However, I would expect to see a description of the errors where it says, "undefined : undefined".

Any advice on getting rid of this?

Answer

This is a bug in gulp-jslint.

Something similar was reported for the 'default' reporter in issue #33. The problem was fixed in this commit for the v1.0.2 release.

However it seems the author of gulp-jslint forgot to apply the same fix to the 'stylish' reporter that you are using.

The best thing would be to report this issue on GitHub and include a link to this question.

Until this is fixed you can use the following workaround:

gulp.task('jslint-server', function () {
  return gulp.src([ 
    'scripts/*.js',
    'web-server.js'
  ])
  .pipe(jslint({ node:true, bitwise:true }))
  //--- workaround ---
  .on('data', function(file) {
    file.jslint.errors.forEach(function(err) {
      err.column = err.column || err.character;
      err.message = err.message || err.reason;
    });
  })
  //------------------
 .pipe(jslint.reporter( 'stylish' ));
});