Skip to content

feat(Schema) Add JSON schema for the extensions config files - #21

Merged
Cyclodex merged 4 commits into
developfrom
claude/issue-5-analysis-9esbaf
Aug 6, 2026
Merged

feat(Schema) Add JSON schema for the extensions config files#21
Cyclodex merged 4 commits into
developfrom
claude/issue-5-analysis-9esbaf

Conversation

@Cyclodex

@Cyclodex Cyclodex commented Aug 5, 2026

Copy link
Copy Markdown
Member

Closes #5

What

Ships a JSON schema for the config files this extension reads, so .vscode/extensionsVersionCheck.json(c) gets validation, autocompletion and hover documentation in the editor — the "built in help" the issue asked for, comparable to what VS Code offers for the original extensions.json.

It is contributed via contributes.jsonValidation, so it is pure metadata: no activation event, no runtime code, nothing to load.

"jsonValidation": [
  {
    "fileMatch": [
      "**/.vscode/extensions*.json",
      "**/.vscode/extensions*.jsonc",
      "!**/.vscode/extensions.json"
    ],
    "url": "./schemas/extensionsVersionCheck.schema.json"
  }
]

The fileMatch mirrors the discovery glob in src/utils.ts (**/.vscode/extensions*.{json,jsonc}), so every file the extension actually reads is covered.

Why .vscode/extensions.json is excluded

VS Code registers its own schema for that file and combines contributed schemas with the built-in one rather than replacing it. Its schema declares additionalProperties: false and restricts entries to plain publisher.name, so:

  • a second schema on that file would only add duplicate diagnostics
  • it would still flag publisher.name@1.0.0 entries as invalid, and we cannot suppress that

Excluding it keeps the diagnostics clean and matches what the README already recommends: version ranges belong in extensionsVersionCheck.json(c). Note that exclusion patterns must stay last in fileMatch — the last matching pattern wins.

What the schema gives you

  • unknown properties and wrong types are reported
  • entries are checked against ${publisher}.${name}[@versionRange], with a custom patternErrorMessage
  • hover documentation on both arrays, including the supported range forms
  • snippets for adding an entry with or without a version range

The version part is matched permissively on purpose. A strict SemVer regex would reject documented forms such as 0.1 - 0.9, 0.* or prerelease versions; real range validation is semver's job at runtime.

Verification

  • Validated with vscode-json-languageservice (the very library VS Code uses): the schema resolves for extensionsVersionCheck.json(c) and other extensions* variants including subfolders, does not claim .vscode/extensions.json, and reports zero diagnostics on the exampleProject/ fixtures.
  • vsce ls confirms schemas/extensionsVersionCheck.schema.json is included in the packaged VSIX.
  • npm run compile, npm run lint and npm run test:unit all pass (32 tests, 6 new).

New unit tests in src/test/unit/schema.test.ts keep the contribution honest: the schema file exists and is referenced, the built-in extensions.json stays excluded, the fileMatch stays in sync with the discovery glob, and every entry used in the exampleProject/ fixtures is accepted by the pattern and is a valid SemVer range according to parseUnwantedEntry + semver.

Notes

  • Based on develop, per the branching convention in CLAUDE.md.
  • The CHANGELOG entry sits under [Unreleased] — no version bump, so src/config/releaseMessages.conf.ts is untouched. Happy to fold both into a release commit if you prefer.
  • Possible follow-ups, out of scope here: a DiagnosticCollection that validates SemVer ranges (and would also reach extensions.json), completion of installed extension IDs, and publishing the schema to SchemaStore.

Generated by Claude Code

Cyclodex and others added 4 commits August 6, 2026 00:45
Contributes a JSON schema via "contributes.jsonValidation" so the
".vscode/extensions*.json(c)" files get validation, autocompletion and
hover documentation in the editor, similar to the original
"extensions.json".

The built-in ".vscode/extensions.json" is excluded from the file match,
since VSCode already provides its own schema for that file.

Closes #5

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJF6ffB8m6M5TKuBTwCKfT
Registers the schema via "contributes.jsonValidation", documents the
editor support in the README and covers the contribution with unit
tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJF6ffB8m6M5TKuBTwCKfT
@Cyclodex
Cyclodex merged commit 0963c6d into develop Aug 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant