From 2c6696dd3a80095bd5765635243ef2fa64df7e18 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sat, 21 Nov 2026 23:08:11 +0800 Subject: [PATCH] fix(json): validate JSON files and map SchemaStore schemas for common config files vscode-json-language-server validates nothing unless `json.validate.enable` is set, so even a file's own `$schema` was ignored. Turn validation on and associate package.json, tsconfig/jsconfig, ESLint, Prettier, Babel, Lerna, Turborepo, SWC and Composer configuration files with their published schemas, for both JSON and JSON with Comments. --- languages/json.toml | 45 ++++++++++++++++++++++++++++++++++++++++++++ languages/jsonc.toml | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/languages/json.toml b/languages/json.toml index f7010dffa..34403bc0a 100644 --- a/languages/json.toml +++ b/languages/json.toml @@ -13,3 +13,48 @@ command = "vscode-json-language-server" args = ["--stdio"] initialization-options = { provideFormatter = true } install-hint = "npm i -g vscode-langservers-extracted" + +# Validation is off in vscode-json-language-server unless enabled. Schemas from SchemaStore for +# common configuration files; a `$schema` in the file itself still wins. +[language-servers.settings.json.validate] +enable = true + +[[language-servers.settings.json.schemas]] +fileMatch = ["package.json"] +url = "https://json.schemastore.org/package.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["tsconfig.json", "tsconfig.*.json"] +url = "https://json.schemastore.org/tsconfig.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["jsconfig.json", "jsconfig.*.json"] +url = "https://json.schemastore.org/jsconfig.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".eslintrc", ".eslintrc.json"] +url = "https://json.schemastore.org/eslintrc.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".prettierrc", ".prettierrc.json"] +url = "https://json.schemastore.org/prettierrc.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".babelrc", ".babelrc.json", "babel.config.json"] +url = "https://json.schemastore.org/babelrc.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["lerna.json"] +url = "https://json.schemastore.org/lerna.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["turbo.json"] +url = "https://turbo.build/schema.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".swcrc"] +url = "https://swc.rs/schema.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["composer.json"] +url = "https://getcomposer.org/schema.json" diff --git a/languages/jsonc.toml b/languages/jsonc.toml index d90e5a655..c32b4a235 100644 --- a/languages/jsonc.toml +++ b/languages/jsonc.toml @@ -15,3 +15,48 @@ command = "vscode-json-language-server" args = ["--stdio"] initialization-options = { provideFormatter = true } install-hint = "npm i -g vscode-langservers-extracted" + +# Validation is off in vscode-json-language-server unless enabled. Schemas from SchemaStore for +# common configuration files; a `$schema` in the file itself still wins. +[language-servers.settings.json.validate] +enable = true + +[[language-servers.settings.json.schemas]] +fileMatch = ["package.json"] +url = "https://json.schemastore.org/package.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["tsconfig.json", "tsconfig.*.json"] +url = "https://json.schemastore.org/tsconfig.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["jsconfig.json", "jsconfig.*.json"] +url = "https://json.schemastore.org/jsconfig.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".eslintrc", ".eslintrc.json"] +url = "https://json.schemastore.org/eslintrc.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".prettierrc", ".prettierrc.json"] +url = "https://json.schemastore.org/prettierrc.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".babelrc", ".babelrc.json", "babel.config.json"] +url = "https://json.schemastore.org/babelrc.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["lerna.json"] +url = "https://json.schemastore.org/lerna.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["turbo.json"] +url = "https://turbo.build/schema.json" + +[[language-servers.settings.json.schemas]] +fileMatch = [".swcrc"] +url = "https://swc.rs/schema.json" + +[[language-servers.settings.json.schemas]] +fileMatch = ["composer.json"] +url = "https://getcomposer.org/schema.json"