feat(schema): ship JSON Schema for editor autocomplete - #15
Merged
Conversation
Hand-written schema/structlint.schema.json (draft-07 for yaml-language-
server compatibility) covering every field on config.Config, with
additionalProperties: false throughout so editors squiggle the same
typos the strict parser rejects at run time. Users get completion,
hover docs, and pre-run validation with a one-line modeline.
Spec: docs/specs/008-json-schema.md.
- schema/structlint.schema.json — full field coverage, shared severity
enum, `required` arrays mirror Config.Validate() invariants, top-level
$schema carve-out documented for JSON configs.
- .structlint.yaml gains `schema/**` in allowedPaths (self-validation
lockstep — required by the roadmap risk 5 rule).
- test/schema_test.go (mixed: reflection sync test in-process, self-
validation is binary-based):
- JSON validity + draft-07 + top-level additionalProperties:false
- every object node declares additionalProperties:false (walked)
- every yaml tag on config.Config appears at the matching schema path
(drift guard: new fields without a schema entry break CI)
- binary self-validate succeeds with schema/ present
- docs/user/configuration.md: yaml-language-server modeline snippet
and JSON `$schema` variant.
SchemaStore submission is tracked as an out-of-repo follow-up (PR to
SchemaStore/schemastore mapping .structlint.{yaml,yml,json}).
StructLint — All checks passed109 rules validated against
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Drift guard
New `test/schema_test.go` reflects over `config.Config` and asserts every yaml tag appears at the matching path in the schema. Adding a config field without touching the schema breaks CI with an actionable message. Also walks every object node in the schema asserting `additionalProperties: false` — protection against silent drift into permissiveness.
The modeline
```yaml
yaml-language-server: $schema=https://raw.githubusercontent.com/AxeForging/structlint/main/schema/structlint.schema.json
```
Documented in `docs/user/configuration.md` (and the JSON `"$schema"` variant).
Backward compatibility
Follow-up (out of repo)
SchemaStore submission tracked separately — PR to `SchemaStore/schemastore` mapping `.structlint.{yaml,yml,json}` after this ships in a tagged release.
Test plan