]>
Commit | Line | Data |
---|---|---|
64bb1bce BB |
1 | <job> |
2 | <script src="jslint-core.js" language="javascript"></script> | |
3 | <script language="javascript"> | |
4 | /*global JSLINT load readline WScript */ | |
5 | ||
6 | var readSTDIN = function() { | |
7 | var line, | |
8 | input = [], | |
9 | emptyCount = 0, | |
10 | i; | |
11 | ||
12 | var stdIn = WScript.stdIn, | |
13 | stdOut = WScript.stdOut; | |
14 | ||
15 | while (!stdIn.atEndofStream) { | |
16 | line = stdIn.readLine(); | |
17 | input.push(line); | |
18 | } | |
19 | ||
20 | return input.join("\n"); | |
21 | }; | |
22 | ||
23 | var body = readSTDIN() || arguments[0], | |
24 | ok = JSLINT(body), | |
25 | i, | |
26 | error, | |
27 | errorType, | |
28 | nextError, | |
29 | errorCount, | |
30 | WARN = 'WARNING', | |
31 | ERROR = 'ERROR'; | |
32 | ||
33 | if (!ok) { | |
34 | errorCount = JSLINT.errors.length; | |
35 | for (i = 0; i < errorCount; i += 1) { | |
36 | error = JSLINT.errors[i]; | |
37 | errorType = WARN; | |
38 | if (error && error.reason && error.reason.match(/^Stopping/) === null) { | |
39 | // If jslint stops next, this was an actual error | |
40 | if (nextError && nextError.reason && nextError.reason.match(/^Stopping/) !== null) { | |
41 | errorType = ERROR; | |
42 | } | |
43 | WScript.echo([error.line, error.character, errorType, error.reason].join(":")); | |
44 | } | |
45 | } | |
46 | } | |
47 | </script> | |
48 | </job> |