feat(linter): detect token name collisions for flat vs grouped keys#150
Open
Arshgill01 wants to merge 1 commit into
Open
feat(linter): detect token name collisions for flat vs grouped keys#150Arshgill01 wants to merge 1 commit into
Arshgill01 wants to merge 1 commit into
Conversation
Adds duplicate and collision detection to the model builder for nested and flat token keys, preventing silent overwrites in the symbol table.
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.
Closes #149
Requested by @davideast in #68:
What this does
forEachLeaf(merged in #103) enables arbitrary nesting depth forcolors,rounded, andspacingtokens. As a side-effect it is now possible to write aDESIGN.mdwhere two differently-structured keys resolve to the same symbol table entry with no diagnostic emitted. Two collision shapes exist:Case 1 — Duplicate dot path
A flat string key whose literal value matches an existing nested token's dot-separated path:
Case 2 — Flat/grouped name collision
A nested token whose path, when dots are replaced by hyphens, matches a flat key that is already registered:
In both cases the offending token is skipped (not written to the symbol table) and an
error-severity finding is emitted so the user sees it at lint time, before the Tailwind v4 emitter processes the output. Behaviour is consistent across all three token categories.Changes
packages/cli/src/linter/model/handler.tsseenKeys(Set<string>) andseenNormalized(Map<string, string>) tracking inside thecolors,rounded, andspacingPhase 1forEachLeafcallbackspackages/cli/src/linter/model/handler.test.tsVerification