Skip to content
Permalink
Browse files

Added in integrated JSLint checking against the jQuery source. Just r…

…un 'make lint' to see the result.
  • Loading branch information
jeresig committed Mar 2, 2010
1 parent dcf0fa5 commit 950b5d64a27994db1697eb4e605f5ea48ad8021b
Showing with 5,548 additions and 3 deletions.
  1. +8 −3 Makefile
  2. +4 −0 README.md
  3. BIN build/js.jar
  4. +36 −0 build/jslint-check.js
  5. +5,500 −0 build/jslint.js
@@ -29,11 +29,12 @@ JQ_MIN = ${DIST_DIR}/jquery.min.js
JQ_VER = `cat version.txt`
VER = sed s/@VERSION/${JQ_VER}/

RHINO = java -jar ${BUILD_DIR}/js.jar
MINJAR = java -jar ${BUILD_DIR}/google-compiler-20091218.jar

DATE=`git log -1 | grep Date: | sed 's/[^:]*: *//'`

all: jquery min
all: jquery lint min
@@echo "jQuery build complete."

${DIST_DIR}:
@@ -49,7 +50,7 @@ init:
jquery: ${DIST_DIR} selector ${JQ}
jq: ${DIST_DIR} ${JQ}

${JQ}: ${MODULES}
${JQ}: selector ${MODULES}
@@echo "Building" ${JQ}

@@mkdir -p ${DIST_DIR}
@@ -58,10 +59,14 @@ ${JQ}: ${MODULES}
sed 's/Date:./&'"${DATE}"'/' | \
${VER} > ${JQ};

selector: init
selector: ${DIST_DIR} init
@@echo "Building selector code from Sizzle"
@@sed '/EXPOSE/r src/sizzle-jquery.js' src/sizzle/sizzle.js > src/selector.js

lint: ${JQ}
@@echo "Checking jQuery against JSLint..."
@@${RHINO} build/jslint-check.js

min: ${JQ_MIN}

${JQ_MIN}: ${JQ}
@@ -36,6 +36,10 @@ Makes: ./dist/jquery.js
A compressed version of jQuery (made the Closure Compiler).
Makes: ./dist/jquery.min.js

`make lint`

Tests a build of jQuery against JSLint, looking for potential errors or bits of confusing code.

`make selector`

Builds the selector library for jQuery from Sizzle.
BIN +794 KB build/js.jar
Binary file not shown.
@@ -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." );
}

0 comments on commit 950b5d6

Please sign in to comment.
You can’t perform that action at this time.