Skip to content

Commit 950b5d6

Browse files
committed
Added in integrated JSLint checking against the jQuery source. Just run 'make lint' to see the result.
1 parent dcf0fa5 commit 950b5d6

File tree

5 files changed

+5548
-3
lines changed

5 files changed

+5548
-3
lines changed

Makefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ JQ_MIN = ${DIST_DIR}/jquery.min.js
2929
JQ_VER = `cat version.txt`
3030
VER = sed s/@VERSION/${JQ_VER}/
3131

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

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

36-
all: jquery min
37+
all: jquery lint min
3738
@@echo "jQuery build complete."
3839

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

52-
${JQ}: ${MODULES}
53+
${JQ}: selector ${MODULES}
5354
@@echo "Building" ${JQ}
5455

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

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

66+
lint: ${JQ}
67+
@@echo "Checking jQuery against JSLint..."
68+
@@${RHINO} build/jslint-check.js
69+
6570
min: ${JQ_MIN}
6671

6772
${JQ_MIN}: ${JQ}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Makes: ./dist/jquery.js
3636
A compressed version of jQuery (made the Closure Compiler).
3737
Makes: ./dist/jquery.min.js
3838

39+
`make lint`
40+
41+
Tests a build of jQuery against JSLint, looking for potential errors or bits of confusing code.
42+
3943
`make selector`
4044

4145
Builds the selector library for jQuery from Sizzle.

build/js.jar

794 KB
Binary file not shown.

build/jslint-check.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
load("build/jslint.js");
2+
3+
var src = readFile("dist/jquery.js");
4+
5+
JSLINT(src, { evil: true, forin: true });
6+
7+
// All of the following are known issues that we think are 'ok'
8+
// (in contradiction with JSLint) more information here:
9+
// http://docs.jquery.com/JQuery_Core_Style_Guidelines
10+
var ok = {
11+
"Expected an identifier and instead saw 'undefined' (a reserved word).": true,
12+
"Use '===' to compare with 'null'.": true,
13+
"Use '!==' to compare with 'null'.": true,
14+
"Expected an assignment or function call and instead saw an expression.": true,
15+
"Expected a 'break' statement before 'case'.": true
16+
17+
};
18+
19+
var e = JSLINT.errors, found = 0, w;
20+
21+
for ( var i = 0; i < e.length; i++ ) {
22+
w = e[i];
23+
24+
if ( !ok[ w.reason ] ) {
25+
found++;
26+
print( "\n" + w.evidence + "\n" );
27+
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
28+
}
29+
}
30+
31+
if ( found > 0 ) {
32+
print( "\n" + found + " Error(s) found." );
33+
34+
} else {
35+
print( "JSLint check passed." );
36+
}

0 commit comments

Comments
 (0)