Merge branch '2.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / 3rdParty / codemirror / addon / lint / json-lint.js
CommitLineData
77b7b761
TD
1// Depends on jsonlint.js from https://github.com/zaach/jsonlint
2
837afb80
TD
3// declare global: jsonlint
4
5(function(mod) {
6 if (typeof exports == "object" && typeof module == "object") // CommonJS
7 mod(require("../../lib/codemirror"));
8 else if (typeof define == "function" && define.amd) // AMD
9 define(["../../lib/codemirror"], mod);
10 else // Plain browser env
11 mod(CodeMirror);
12})(function(CodeMirror) {
13"use strict";
14
15CodeMirror.registerHelper("lint", "json", function(text) {
77b7b761
TD
16 var found = [];
17 jsonlint.parseError = function(str, hash) {
18 var loc = hash.loc;
19 found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
20 to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
21 message: str});
22 };
23 try { jsonlint.parse(text); }
24 catch(e) {}
25 return found;
837afb80
TD
26});
27
28});