Files
luos/gulliver/js/codemirror/addon/lint/json-lint.js

18 lines
556 B
JavaScript
Raw Normal View History

2013-03-28 15:44:44 -04:00
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
// declare global: jsonlint
CodeMirror.registerHelper("lint", "json", function(text) {
2013-03-28 15:44:44 -04:00
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