summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon/lint/coffeescript-lint.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/addon/lint/coffeescript-lint.js')
-rwxr-xr-xpublic/vendor/codemirror/addon/lint/coffeescript-lint.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/public/vendor/codemirror/addon/lint/coffeescript-lint.js b/public/vendor/codemirror/addon/lint/coffeescript-lint.js
new file mode 100755
index 00000000..7e39428f
--- /dev/null
+++ b/public/vendor/codemirror/addon/lint/coffeescript-lint.js
@@ -0,0 +1,41 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
+
+// declare global: coffeelint
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.registerHelper("lint", "coffeescript", function(text) {
+ var found = [];
+ var parseError = function(err) {
+ var loc = err.lineNumber;
+ found.push({from: CodeMirror.Pos(loc-1, 0),
+ to: CodeMirror.Pos(loc, 0),
+ severity: err.level,
+ message: err.message});
+ };
+ try {
+ var res = coffeelint.lint(text);
+ for(var i = 0; i < res.length; i++) {
+ parseError(res[i]);
+ }
+ } catch(e) {
+ found.push({from: CodeMirror.Pos(e.location.first_line, 0),
+ to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
+ severity: 'error',
+ message: e.message});
+ }
+ return found;
+});
+
+});