aboutsummaryrefslogtreecommitdiff
path: root/vim/ftplugin/javascript/jslint/runjslint.wsf
diff options
context:
space:
mode:
authorBen Beltran <ben@freshout.us>2013-03-25 16:36:57 -0600
committerBen Beltran <ben@freshout.us>2013-03-25 16:36:57 -0600
commit64bb1bce986ea027679febb5d6a91c64cc815368 (patch)
tree0f8e4b774faf1619a8f2322f6206553e12292132 /vim/ftplugin/javascript/jslint/runjslint.wsf
parent30a7092fe25d693f33637a92d2abb5ba1c4aea58 (diff)
Update the stuff
Diffstat (limited to 'vim/ftplugin/javascript/jslint/runjslint.wsf')
-rw-r--r--vim/ftplugin/javascript/jslint/runjslint.wsf48
1 files changed, 48 insertions, 0 deletions
diff --git a/vim/ftplugin/javascript/jslint/runjslint.wsf b/vim/ftplugin/javascript/jslint/runjslint.wsf
new file mode 100644
index 0000000..d6c24bd
--- /dev/null
+++ b/vim/ftplugin/javascript/jslint/runjslint.wsf
@@ -0,0 +1,48 @@
+<job>
+<script src="jslint-core.js" language="javascript"></script>
+<script language="javascript">
+/*global JSLINT load readline WScript */
+
+var readSTDIN = function() {
+ var line,
+ input = [],
+ emptyCount = 0,
+ i;
+
+ var stdIn = WScript.stdIn,
+ stdOut = WScript.stdOut;
+
+ while (!stdIn.atEndofStream) {
+ line = stdIn.readLine();
+ input.push(line);
+ }
+
+ return input.join("\n");
+};
+
+var body = readSTDIN() || arguments[0],
+ ok = JSLINT(body),
+ i,
+ error,
+ errorType,
+ nextError,
+ errorCount,
+ WARN = 'WARNING',
+ ERROR = 'ERROR';
+
+if (!ok) {
+ errorCount = JSLINT.errors.length;
+ for (i = 0; i < errorCount; i += 1) {
+ error = JSLINT.errors[i];
+ errorType = WARN;
+ if (error && error.reason && error.reason.match(/^Stopping/) === null) {
+ // If jslint stops next, this was an actual error
+ if (nextError && nextError.reason && nextError.reason.match(/^Stopping/) !== null) {
+ errorType = ERROR;
+ }
+ WScript.echo([error.line, error.character, errorType, error.reason].join(":"));
+ }
+ }
+}
+</script>
+</job>