move a few things away in to-be-integrated/
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / addon / lint / json-lint.js
diff --git a/to-be-integrated/third-party/codemirror-3.15/addon/lint/json-lint.js b/to-be-integrated/third-party/codemirror-3.15/addon/lint/json-lint.js
new file mode 100644 (file)
index 0000000..1dfc6b8
--- /dev/null
@@ -0,0 +1,15 @@
+// Depends on jsonlint.js from https://github.com/zaach/jsonlint
+
+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;
+});
+CodeMirror.jsonValidator = CodeMirror.lint.json; // deprecated