Skip to content

Commit 0bfda9c

Browse files
authored
Merge pull request #3825 from Geethegreat/json-lint
2 parents b5e6852 + bdff696 commit 0bfda9c

File tree

3 files changed

+3791
-32773
lines changed

3 files changed

+3791
-32773
lines changed

client/modules/IDE/components/Editor/stateUtils.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646

4747
import { css } from '@codemirror/lang-css';
4848
import { html } from '@codemirror/lang-html';
49-
import { json } from '@codemirror/lang-json';
49+
import { json, jsonParseLinter } from '@codemirror/lang-json';
5050
import { xml } from '@codemirror/lang-xml';
5151
import { linter } from '@codemirror/lint';
5252
import { JSHINT } from 'jshint';
@@ -232,6 +232,15 @@ function makeJsLinter(callback) {
232232
};
233233
}
234234

235+
function makeJsonLinter(callback) {
236+
const baseJsonLinter = jsonParseLinter();
237+
return (view) => {
238+
const diagnostics = baseJsonLinter(view);
239+
if (callback) callback(diagnostics);
240+
return diagnostics;
241+
};
242+
}
243+
235244
function getFileLinter(fileName, callback) {
236245
const fileMode = getFileMode(fileName);
237246

@@ -242,6 +251,8 @@ function getFileLinter(fileName, callback) {
242251
return linter(makeHtmlLinter(callback));
243252
case 'css':
244253
return linter(makeCssLinter(callback));
254+
case 'application/json':
255+
return linter(makeJsonLinter(callback));
245256
default:
246257
return null;
247258
}

0 commit comments

Comments
 (0)