Skip to content

Commit

Permalink
more predefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Moore committed Nov 3, 2010
1 parent 4a8c68b commit 07b1250
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 86 deletions.
102 changes: 51 additions & 51 deletions componentbuild/lib/jslint/jslint-console.js
@@ -1,9 +1,9 @@
/**
* Javascript Shell Script to Load and JSLint js files through Rhino Javascript Shell
* The jslint source file is expected as the first argument, followed by the list of JS files to JSLint
*
* e.g.
* java -j js.jar /tools/fulljslint.js testFile1.js testFile2.js testFile3.js
*
* e.g.
* java -j js.jar /tools/fulljslint.js testFile1.js testFile2.js testFile3.js
**/

var jslintsrc = arguments.splice(0,1);
Expand All @@ -13,59 +13,59 @@ load(jslintsrc);

(function(){ // Just to keep stuff seperate from JSLINT code

var OPTS = {
browser : true,
//laxLineEnd : true,
undef: true,
newcap: false,
predef:["YUI"]
};

function test(jsFile) {

print("Running JSLint on : " + jsFile);

var js = readFile(jsFile);
var OPTS = {
browser : true,
//laxLineEnd : true,
undef: true,
newcap: false,
predef:["YUI", "window", "YUI_config", "YAHOO", "YAHOO_config", "opera", "exports", "document", "navigator", "console"]
};

var success = JSLINT(js, OPTS);
if (success) {
print("- OK");
} else {
print(" \n");
function test(jsFile) {

print("Running JSLint on : " + jsFile);

var js = readFile(jsFile);

var success = JSLINT(js, OPTS);
if (success) {
print("- OK");
} else {
print(" \n");

for (var i=0; i < JSLINT.errors.length; ++i) {
var e = JSLINT.errors[i];
if (e) {
print("\t" + e.line + ", " + e.character + ": " + e.reason + "\n\t" + clean(e.evidence) + "\n");
}
}
print(" \n");

for (var i=0; i < JSLINT.errors.length; ++i) {
var e = JSLINT.errors[i];
if (e) {
print("\t" + e.line + ", " + e.character + ": " + e.reason + "\n\t" + clean(e.evidence) + "\n");
}
}
print(" \n");

// Last item is null if JSLint hit a fatal error
if (JSLINT.errors && JSLINT.errors[JSLINT.errors.length-1] === null) {
throw new Error("Fatal JSLint Exception. Stopped lint");
}
}
}
function clean(str) {
var trimmed = "";
if (str) {
if(str.length <= 500) {
trimmed = str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
} else {
trimmed = "[Code Evidence Omitted: Greater than 500 chars]";
}
}
return trimmed;
}
function jslint(aScripts) {
for (var i = 0; i < aScripts.length; ++i) {
test(aScripts[i]);
}
};
jslint(scripts);
}
}

function clean(str) {
var trimmed = "";
if (str) {
if(str.length <= 500) {
trimmed = str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
} else {
trimmed = "[Code Evidence Omitted: Greater than 500 chars]";
}
}
return trimmed;
}

function jslint(aScripts) {
for (var i = 0; i < aScripts.length; ++i) {
test(aScripts[i]);
}
};

jslint(scripts);

})();
70 changes: 35 additions & 35 deletions componentbuild/lib/jslint/jslint-node.js
@@ -1,9 +1,9 @@
/**
* Javascript Shell Script to Load and JSLint js files through Rhino Javascript Shell
* The jslint source file is expected as the first argument, followed by the list of JS files to JSLint
*
* e.g.
* java -j js.jar /tools/fulljslint.js testFile1.js testFile2.js testFile3.js
*
* e.g.
* java -j js.jar /tools/fulljslint.js testFile1.js testFile2.js testFile3.js
**/

JSLINT = require("./fulljslint").JSLINT;
Expand All @@ -12,27 +12,27 @@ JSLINT = require("./fulljslint").JSLINT;

var PORT = parseInt(process.argv[2]) || 8081;

var OPTS = {
browser : true,
//laxLineEnd : true,
var OPTS = {
browser : true,
//laxLineEnd : true,
undef: true,
newcap: false,
predef:["YUI"]
};
function test(js) {
newcap: false,
predef:["YUI", "window", "YUI_config", "YAHOO", "YAHOO_config", "opera", "exports", "document", "navigator", "console"]
};

function test(js) {
var body = "", code = 200;

var success = JSLINT(js, OPTS);
if (success) {
return "OK";
} else {
for (var i=0; i < JSLINT.errors.length; ++i) {
var e = JSLINT.errors[i];
if (e) {
body += ("\t" + e.line + ", " + e.character + ": " + e.reason + "\n\t" + clean(e.evidence) + "\n");
}
}
if (success) {
return "OK";
} else {
for (var i=0; i < JSLINT.errors.length; ++i) {
var e = JSLINT.errors[i];
if (e) {
body += ("\t" + e.line + ", " + e.character + ": " + e.reason + "\n\t" + clean(e.evidence) + "\n");
}
}
body += "\n";

// Last item is null if JSLint hit a fatal error
Expand All @@ -43,20 +43,20 @@ JSLINT = require("./fulljslint").JSLINT;
"content" : body,
"code" : code
};
}
}
function clean(str) {
var trimmed = "";
if (str) {
if(str.length <= 500) {
trimmed = str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
} else {
trimmed = "[Code Evidence Omitted: Greater than 500 chars]";
}
}
return trimmed;
}
}
}

function clean(str) {
var trimmed = "";
if (str) {
if(str.length <= 500) {
trimmed = str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
} else {
trimmed = "[Code Evidence Omitted: Greater than 500 chars]";
}
}
return trimmed;
}

var qs = require("querystring");
var fs = require("fs");
Expand Down Expand Up @@ -115,4 +115,4 @@ JSLINT = require("./fulljslint").JSLINT;
}, 10000);
})();
})();

0 comments on commit 07b1250

Please sign in to comment.