diff --git a/src/components/sources/SourceTypeEditor.jsx b/src/components/sources/SourceTypeEditor.jsx index dff11d72..2f8c1542 100644 --- a/src/components/sources/SourceTypeEditor.jsx +++ b/src/components/sources/SourceTypeEditor.jsx @@ -214,6 +214,11 @@ class GeoJSONSourceJSONEditor extends React.Component { { this.props.onChange({ ...this.props.source, diff --git a/src/components/util/codemirror-mgl.js b/src/components/util/codemirror-mgl.js index f4ab3d4b..0e180957 100644 --- a/src/components/util/codemirror-mgl.js +++ b/src/components/util/codemirror-mgl.js @@ -12,6 +12,30 @@ CodeMirror.defineMode("mgl", function(config, parserConfig) { ); }); +CodeMirror.registerHelper("lint", "json", function(text) { + const found = []; + + // NOTE: This was modified from the original to remove the global, also the + // old jsonlint API was 'jsonlint.parseError' its now + // 'jsonlint.parser.parseError' + jsonlint.parser.parseError = function(str, hash) { + const 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) { + // Do nothing we catch the error above + } + return found; +}); + CodeMirror.registerHelper("lint", "mgl", function(text, opts, doc) { const found = []; const {parser} = jsonlint;