feat: add prose-token-leak lint rule - #167
Open
zachshallbetter wants to merge 1 commit into
Open
Conversation
Add a new lint rule, prose-token-leak, to flag literal token value duplication in markdown body text to prevent documentation drift (Issue google-labs-code#16). * Extend Model State: - Add 'documentSections' to DesignSystemState type interface and forward it inside the model compilation handler. * Rule Implementation & Registration: - Add 'prose-token-leak.ts' containing regex evaluation of CSS dimensions and hex values, omitting markdown links, HTML tags/comments, headings, and code blocks. - Register the rule in index.ts and update test assertions to expect 12 rule descriptors. * Documentation: - Update spec.mdx to describe the prose token replication policy, and compile docs/spec.md.
zachshallbetter
force-pushed
the
feat/prose-token-leak
branch
from
August 11, 2026 03:55
ed92797 to
fbcc612
Compare
Contributor
Author
|
Also, future extensions might/could include:
|
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.
Added a new lint rule,
prose-token-leak, to flag literal token value duplication in markdown body text to prevent documentation drift (resolves Issue #16).Background & Motivation
The spec explicity separates machine-readable tokens (YAML frontmatter) and human-readable context (markdown body). When authors duplicate literal values (such as hex colors
#ffffff, functional colorsrgb(...)/hsl(...), or dimensions16px) in their prose descriptions or tables, it introduces a dual source of truth. If token values are updated, the prose is frequently forgotten and drifts out of sync.As discussed in Issue #16, there is community consensus that:
{colors.primary},body-md type scale).This rule builds on the pattern established in PR #155 (custom linter checks and omitted-sections validations) by keeping standard linter warnings as the primary gate for format compliance.
Relation to other PRs
omittedvalidations in PR feat: add omitted frontmatter key to suppress expected-missing lint warnings #155).prose-token-leakrule directly reinforces that philosophy by steering authors away from writing hardcoded literal values in prose and encouraging clean token usage.Changes
DesignSystemStateto includedocumentSectionsto expose parsed section content to the rules.input.documentSectionsinModelHandler.prose-token-leak.tscontaining the validation logic. Regex patterns flag literal hex colors, functional color notations (rgb,rgba,hsl,hsla), and CSS dimensions.{colors.primary}).rules/index.tsand update rules count assertions in test files.spec.mdxto define the prose token duplication policy.docs/spec.md(see docs/spec.md#L8).