GPQAPP
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4// Depends on jsonlint.js from https://github.com/zaach/jsonlint
5
6// declare global: jsonlint
7
8(function(mod) {9if (typeof exports == "object" && typeof module == "object") // CommonJS10mod(require("../../lib/codemirror"));11else if (typeof define == "function" && define.amd) // AMD12define(["../../lib/codemirror"], mod);13else // Plain browser env14mod(CodeMirror);15})(function(CodeMirror) {16"use strict";17
18CodeMirror.registerHelper("lint", "json", function(text) {19var found = [];20if (!window.jsonlint) {21if (window.console) {22window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run.");23}24return found;25}26// for jsonlint's web dist jsonlint is exported as an object with a single property parser, of which parseError27// is a subproperty28var jsonlint = window.jsonlint.parser || window.jsonlint29jsonlint.parseError = function(str, hash) {30var loc = hash.loc;31found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),32to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),33message: str});34};35try { jsonlint.parse(text); }36catch(e) {}37return found;38});39
40});41