forked from webmademovies/popcorn-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jslint-check.js
43 lines (37 loc) · 1.21 KB
/
jslint-check.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
load("build/jslint.js");
// 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,
"'e' is already defined.": true,
"Don't make functions within a loop.": true,
"['out'] is better written in dot notation.": true
};
function check(src)
{
JSLINT(src, { evil: true, forin: true, maxerr: 100 });
var e = JSLINT.errors, found = 0, w;
for ( var i = 0; e && i < e.length; i++ ) {
w = e[i];
if ( w && !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." );
}
}
for each (var f in arguments)
{
print( "Linting "+ f );
check(readFile(f));
}