@bhsd/lezer-json
v2.1.0
Published
Lezer-based JSON/JSONC grammar
Readme
@bhsd/lezer-json
This is a fork of @lezer/json and @codemirror/lang-json that adds a dialect for JSONC to provide support for comments and trailing commas.
Installation
You can install the package via npm and import it as a module:
npm install @bhsd/lezer-jsonLanguage Support
import {json} from '@bhsd/lezer-json';
import type {LanguageSupport} from '@codemirror/language';
const jsonLanguageSupport: LanguageSupport = json(),
jsoncLanguageSupport: LanguageSupport = json('jsonc');Language
You can also import the LR language for JSON or JSONC alone.
import {jsonLanguage, jsoncLanguage} from '@bhsd/lezer-json';Lint Source
This package also provides lint sources for JSON or JSONC syntax checking.
import {linter} from '@codemirror/lint';
import {jsonLinter, jsoncLinter} from '@bhsd/lezer-json';
import type {Extension} from '@codemirror/state';
const jsonLintExtension: Extension = linter(jsonLinter),
jsoncLintExtension: Extension = linter(jsoncLinter);