Skip to content

Instantly share code, notes, and snippets.

@nafeger
Created April 6, 2011 14:08
Show Gist options
  • Save nafeger/905709 to your computer and use it in GitHub Desktop.
Save nafeger/905709 to your computer and use it in GitHub Desktop.
Index: src/main/jmvc/steal/clean/clean.js
===================================================================
--- src/main/jmvc/steal/clean/clean.js (revision 510)
+++ src/main/jmvc/steal/clean/clean.js (working copy)
@@ -2,12 +2,18 @@
// using with jslint: js steal/cleanjs path/to/file -jslint
steal.plugins('steal/build').then('//steal/clean/beautify','//steal/clean/jslint','//steal/rhino/prompt', function(steal){
- var lintAndPrint = function(out, predefined){
-
+ var whitespace = function(c) {
+ var rv = '';
+ while (c--) {
+ rv+=' ';
+ }
+ return rv;
+ }
+ var lintAndPrint = function(fileName, out, predefined){
JSLINT(out,{devel: true, forin: true, browser: true, windows: true, rhino: true, predefined : predefined});
- if(JSLINT.errors.length){
- //var lines = out.split('\n'), line, error;
+ var errorCount = JSLINT.errors.length;
+ if(errorCount){
for(var i = 0; i < JSLINT.errors.length; i++){
error = JSLINT.errors[i];
if(!error.evidence){
@@ -15,13 +21,14 @@
}
line = error.evidence.replace(/\t/g," ");
- print(" "+error.line+":<"+error.reason+">:"+error.character+" "+
- line.substring(Math.max(error.character-25, 0),
- Math.min(error.character+25, line.length)).replace(/^\s+/,"")
-
- )
- print(" ")
+ print(" ");
+ print(fileName+":"+error.line+": "+error.reason);
+ print("symbol: "+line.substring(Math.max(error.character-10, 0), Math.min(error.character+10, line.length)));
+ print("location: "+error.character);
+ print(line);
+ print(whitespace(error.character)+"^");
}
+ print (errorCount +" error"+(errorCount > 1 ? "s" : ""))
}
var data = JSLINT.data();
@@ -118,7 +125,7 @@
steal.File(url).save( out )
}
if(options.jslint){
- var errors = lintAndPrint(out, options.predefined || {});
+ var errors = lintAndPrint(url, out, options.predefined || {});
if(errors){
print("quiting because of JSLint Errors");
quit();
@@ -141,7 +148,7 @@
if(out == text){
print("C "+path);
if(options.jslint){
- var errors = lintAndPrint(out, options.predefined || {});
+ var errors = lintAndPrint(url, out, options.predefined || {});
if(errors){
print("quiting because of JSLint Errors");
quit();
@@ -157,7 +164,7 @@
}
if(options.jslint){
- var errors = lintAndPrint(out, options.predefined || {});
+ var errors = lintAndPrint(url, out, options.predefined || {});
if(errors){
print("quiting because of JSLint Errors");
quit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment