Skip to content

feat: warn on token-like frontmatter keys silently ignored by export#105

Open
mvanhorn wants to merge 1 commit into
google-labs-code:mainfrom
mvanhorn:feat/100-token-like-ignored-lint
Open

feat: warn on token-like frontmatter keys silently ignored by export#105
mvanhorn wants to merge 1 commit into
google-labs-code:mainfrom
mvanhorn:feat/100-token-like-ignored-lint

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Adds a new token-like-ignored lint 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 like base_colors or semantic_spacing pass lint silently and are then completely dropped by design.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_colors instead of colors. 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 like meta: { 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 rawValues through to ParsedDesignSystem, and the model layer extracts unknownKeyValues for 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

…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`
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.

lint should warn when frontmatter token-like fields are ignored by export

1 participant