summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon/lint/json-lint.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/addon/lint/json-lint.js')
-rwxr-xr-xpublic/vendor/codemirror/addon/lint/json-lint.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/public/vendor/codemirror/addon/lint/json-lint.js b/public/vendor/codemirror/addon/lint/json-lint.js
new file mode 100755
index 00000000..9dbb616b
--- /dev/null
+++ b/public/vendor/codemirror/addon/lint/json-lint.js
@@ -0,0 +1,31 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Depends on jsonlint.js from https://github.com/zaach/jsonlint
+
+// declare global: jsonlint
+
+(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", "json", function(text) {
+ var found = [];
+ jsonlint.parseError = function(str, hash) {
+ var loc = hash.loc;
+ found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
+ to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
+ message: str});
+ };
+ try { jsonlint.parse(text); }
+ catch(e) {}
+ return found;
+});
+
+});