aboutsummaryrefslogtreecommitdiffstats
path: root/build/jslint-check.js
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-03-01 21:51:44 -0500
committerjeresig <jeresig@gmail.com>2010-03-01 21:51:44 -0500
commit950b5d64a27994db1697eb4e605f5ea48ad8021b (patch)
tree3c436dffcca5714af3194d278a3f61cb485f6801 /build/jslint-check.js
parentdcf0fa5048ef2379d551f29ffa29b14ec5ee09d5 (diff)
downloadjquery-950b5d64a27994db1697eb4e605f5ea48ad8021b.tar.gz
jquery-950b5d64a27994db1697eb4e605f5ea48ad8021b.zip
Added in integrated JSLint checking against the jQuery source. Just run 'make lint' to see the result.
Diffstat (limited to 'build/jslint-check.js')
-rw-r--r--build/jslint-check.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/build/jslint-check.js b/build/jslint-check.js
new file mode 100644
index 000000000..3e9c12639
--- /dev/null
+++ b/build/jslint-check.js
@@ -0,0 +1,36 @@
+load("build/jslint.js");
+
+var src = readFile("dist/jquery.js");
+
+JSLINT(src, { evil: true, forin: true });
+
+// All of the following are known issues that we think are 'ok'
+// (in contradiction with JSLint) more information here:
+// http://docs.jquery.com/JQuery_Core_Style_Guidelines
+var ok = {
+ "Expected an identifier and instead saw 'undefined' (a reserved word).": true,
+ "Use '===' to compare with 'null'.": true,
+ "Use '!==' to compare with 'null'.": true,
+ "Expected an assignment or function call and instead saw an expression.": true,
+ "Expected a 'break' statement before 'case'.": true
+
+};
+
+var e = JSLINT.errors, found = 0, w;
+
+for ( var i = 0; i < e.length; i++ ) {
+ w = e[i];
+
+ if ( !ok[ w.reason ] ) {
+ found++;
+ print( "\n" + w.evidence + "\n" );
+ print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
+ }
+}
+
+if ( found > 0 ) {
+ print( "\n" + found + " Error(s) found." );
+
+} else {
+ print( "JSLint check passed." );
+}