JSON linting

This commit is contained in:
Gregory Schier
2025-11-08 15:24:31 -08:00
parent f2a63087b0
commit 054916b7af
5 changed files with 222 additions and 31 deletions

View File

@@ -19,7 +19,7 @@ import {
indentOnInput,
syntaxHighlighting,
} from '@codemirror/language';
import { lintKeymap } from '@codemirror/lint';
import { linter, lintGutter, lintKeymap } from '@codemirror/lint';
import { search, searchKeymap } from '@codemirror/search';
import type { Extension } from '@codemirror/state';
@@ -45,6 +45,7 @@ import { renderMarkdown } from '../../../lib/markdown';
import { pluralizeCount } from '../../../lib/pluralize';
import { showGraphQLDocExplorerAtom } from '../../graphql/graphqlAtoms';
import type { EditorProps } from './Editor';
import { jsonParseLinter } from './json-lint';
import { pairs } from './pairs/extension';
import { text } from './text/extension';
import type { TwigCompletionOption } from './twig/completion';
@@ -153,6 +154,10 @@ export function getLanguageExtension({
];
}
if (language === 'json') {
extraExtensions.push(linter(jsonParseLinter()), lintGutter());
}
const maybeBase = language ? syntaxExtensions[language] : null;
const base = typeof maybeBase === 'function' ? maybeBase() : null;
if (base == null) {