feat: warn on token-like frontmatter keys silently ignored by export#105
Open
mvanhorn wants to merge 1 commit into
Open
feat: warn on token-like frontmatter keys silently ignored by export#105mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
…er keys Closes google-labs-code#100 Add a new `token-like-ignored` lint rule that warns when a top-level YAML key is not part of the recognized export schema and its value looks like a design-token map (hex colors, CSS dimensions, or typography property names). These keys are silently dropped by `design.md export`, misleading users into thinking their color palette or type scale was exported. - Extend `ParsedDesignSystem` with `rawValues` so the parser carries all raw YAML values through to the model layer - Extend `DesignSystemState` with `unknownKeyValues` populated by `ModelHandler` - New rule `token-like-ignored` in `linter/rules/token-like-ignored.ts` - 10 tests covering hex color maps, font maps, dimension maps, flat scalars, non-token objects, nested maps, and multi-key scenarios - Register rule in `DEFAULT_RULE_DESCRIPTORS` and re-export from public API - Update hardcoded rule-count assertions in `types.test.ts` and `spec.test.ts`
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
Adds a new
token-like-ignoredlint rule that warns when a top-level frontmatter key looks like a design-token map but is not part of the recognized export schema. Currently, keys likebase_colorsorsemantic_spacingpass lint silently and are then completely dropped bydesign.md export. This is especially confusing for LLM-generated DESIGN.md files, where lint success implies export completeness but does not guarantee it.Why this matters
Fixes #100. The reporter's full color palette was silently discarded because their LLM used
base_colorsinstead ofcolors. A warning at lint time surfaces the problem before export swallows the data.Approach
The rule detects "token-like" maps by inspecting leaf values for hex color strings, CSS dimension strings, and typography property names (
fontFamily,fontSize, etc.). A plain metadata object likemeta: { author: "Jane" }stays silent; a map of hex colors or rem values triggers a warning pointing the author toward the correct schema key.To make raw YAML values available at rule evaluation time, the parser now carries
rawValuesthrough toParsedDesignSystem, and the model layer extractsunknownKeyValuesfor keys not in the schema. No changes to the export pipeline are needed. Ten unit tests cover the happy path, edge cases (flat scalars, non-token objects, nested maps), and multi-key scenarios.Fixes #100