Skip to content

Instantly share code, notes, and snippets.

@mikesherov
Created December 12, 2011 05:13
Show Gist options
  • Save mikesherov/1465088 to your computer and use it in GitHub Desktop.
Save mikesherov/1465088 to your computer and use it in GitHub Desktop.
jQuery JSHint specific files
var jshint = require("./lib/jshint").JSHINT,
reader = require("fs").readFileSync,
files = [
"ajax",
"ajax/jsonp",
"ajax/script",
"ajax/xhr",
"attributes",
"callbacks",
"core",
"css",
"data",
"deferred",
"dimensions",
"effects",
"event",
"exports",
"manipulation",
"offset",
"queue",
"sizzle-jquery",
"support",
"traversing",
],
config = {
noarg: true,
nonew: true,
onevar: true,
evil: true,
undef: false,
browser: true,
wsh: true,
eqnull: true,
expr: true,
curly: true,
trailing: true,
predef: [
"define",
"DOMParser"
],
maxerr: 100
},
i = 0,
errors = 0,
src,
str,
filename;
for( ; i < files.length ; i++ ) {
filename = "src/" + files[ i ] + ".js";
if ( !jshint( reader(filename, "utf8"), config ) ) {
jshint.errors.forEach(function( e ) {
if ( !e ) {
return;
}
errors++;
str = e.evidence ? e.evidence : "";
if ( str ) {
str = str.replace( /\t/g, " " ).trim();
console.log( " [" + filename + ":L" + e.line + ":C" + e.character + "] " + e.reason + "\n " + str + "\n");
}
});
}
}
if ( errors === 0 ) {
console.log("JSHint check passed.");
} else {
console.log("JSHint check found " + errors + " errors");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment