Skip to content

Instantly share code, notes, and snippets.

@nfriedly

nfriedly/testcode.js

Created Sep 22, 2012
Embed
What would you like to do?
JSHint ignores the `indent:` option hwen it's passed in globally
// contrived example. This file uses 3 spaces for indentation
function doStuff() {
console.log("Stuff!");
}
#!/usr/bin/env node
var fs = require('fs'),
util = require('util');
var jshint = require('jshint').JSHINT;
var src = fs.readFileSync('./testcode.js').toString();
var success = jshint(src, {indent: 4});
if (success) {
util.puts("The file passed");
} else {
util.puts("The file failed JSHint with the following errors:");
jshint.errors.forEach(function(err){
if (err) { // sometimes there's a null at the end of the errors list
util.error(util.format("\n%s\n%s\nline:%d, character:%d", err.reason, (err.evidence || '').trim(), err.line, err.character))
}
});
}
// expected behavior is an error about onluy using 3 spaces to indent
// actual behavior is that the scripts outputs "The file passed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment