Skip to content

feat: add schema for feature manifest files - #2347

Merged
AprilSylph merged 4 commits into
masterfrom
aprilsylph/feature-schema
Aug 24, 2026
Merged

feat: add schema for feature manifest files#2347
AprilSylph merged 4 commits into
masterfrom
aprilsylph/feature-schema

Conversation

@AprilSylph

@AprilSylph AprilSylph commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Description

I keep getting annoyed at how juvenile docs/Chapter 4.1 - Feature metadata.md seems. Better documentation would look more like the pages on Google's Chrome extension developer docs, with its own type definitions and better clarity about what can and cannot overlap.

Well, that sounds awfully like a schema to me. I think that maybe creating a schema could be a great starting point for writing better documentation, since it forces accurate recording of definitions without the additional effort of explaining too much of anything in English.

As a bonus, we get basic IntelliSense descriptions for properties in feature.json files.

I have to admit鈥擨 had fun doing this.

Screenshots

N/A, dev changes only

Testing steps

  1. Pull this branch locally
  2. Validate our feature.json files against the new schema:
    npx ajv-cli validate --spec=draft2020 -s schemas/feature.json -d 'src/features/*/feature.json'
    

@AprilSylph

Copy link
Copy Markdown
Owner Author

Possible point of contention: should the "json.schemas" VS Code config property be committed, or should we add a "$schema" property to every feature manifest? The former is obviously a lot less lift, but only works with one editor; the latter is more complete but would be more LoC total.

...I think I'm leaning towards the latter, now that I spell it out like that.

- preferences object must have at least one property
- colorPreference.default must be an empty string or a colour hex code
- componentPreference.src must match the pattern /^\/features\/.+\/.+\.js$/
- selectPreference.options must not be empty
@marcustyphoon

Copy link
Copy Markdown
Collaborator

Possible point of contention: should the "json.schemas" VS Code config property be committed, or should we add a "$schema" property to every feature manifest? The former is obviously a lot less lift, but only works with one editor; the latter is more complete but would be more LoC total.

...I think I'm leaning towards the latter, now that I spell it out like that.

Hm, I think either works well. Agreed with your lean, I think.

@AprilSylph

AprilSylph commented Aug 24, 2026

Copy link
Copy Markdown
Owner Author

In implementing the "$schema" properties I realised something about it which is making me lean a little harder in the other direction: it's essentially polluting the final package. 36 added LoC that do absolutely nothing.

If folks want to use other editors to contribute, and stick around long enough to crave dev QoL things like schema validation (which is already an unrealistic circumstance, if the project's history is anything to go on), then we can revisit this decision or commit another editor config file.


Attachments: diff.patch

@marcustyphoon

Copy link
Copy Markdown
Collaborator

Hm, I guess I'm just used to $schema properties at this point, as if they were part of the filetype.

@marcustyphoon

Copy link
Copy Markdown
Collaborator

Aside: I do find the true-json-schema approach interesting to compare to authoring types in typescript (and validating with e.g. typia, which was what I chose for https://github.com/discretize/discretize-gear-optimizer) or authoring in zod. Both seem quite a bit more succinct to author in and read. Things like "minProperties": 1, aren't expressable in typescript, to my knowledge; I have to imagine they are in zod (which I should probably use at some point just to get familiar with it, since it seems pretty ubiquitous).

To my knowledge, you can't get intellisense in a json file using either directly without a hacky VS Code plugin; using either without that would presumably either requiring running a script to convert the source of truth into a schema file wheneve it's changed (meh) or changing the metadata files to be js/ts default exports (also meh, besides that you get jsonc features for free; no-trailing-commas requirements should be banned by some kind of international treaty).

So, not practical, really, but interesting.

@AprilSylph
AprilSylph merged commit 8ea5b73 into master Aug 24, 2026
5 checks passed
@AprilSylph
AprilSylph deleted the aprilsylph/feature-schema branch August 24, 2026 10:39
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.

2 participants