public
Last active

A reporter that discards all warnings about mixed tabs and errors

  • Download Gist
notabs.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/**
* notabs.js
*
* A reporter that discards all warnings about mixed tabs and errors.
* This file was based on our default reporter so output is the same.
*
* Usage:
* jshint myfile.js --reporter=notabs.js
*/
 
module.exports = {
reporter: function (results) {
var len = results.length;
var str = "";
 
results.forEach(function (result) {
var file = result.file;
var error = result.error;
 
if (error.reason === "Mixed spaces and tabs.") {
return;
}
 
str += file + ': line ' + error.line + ', col ' +
error.character + ', ' + error.reason + '\n';
});
 
if (str) {
process.stdout.write(str + "\n" + len + ' error' + ((len === 1) ? '' : 's') + "\n");
}
}
};

Why is this external to JSHint? It seems like a common request to supress mixed tabs and spaces.

Hi. How do I use it in Sublime Text 2 with SublimeLinter extension? Tks

I agree this should just be a config option.

There are 2 other solutions, choose the one that best suits your needs:

Since it wasn't clear to me, @jlgrall's suggested options can be dropped into your ~/.jshintrc config file or (I think) SublimeLinter's jshint_options config block.

// .jshintrc
{
  "smarttabs": true
}
// .jshintrc
{
  "-W099": true
}
// SublimeLinter.sublime-settings
{
  "jshint_options":
  {
    "-W099": true
  }
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.