Repository navigation
fix(sheet): reject theme tokens of different kinds sharing a variable - #908
Merged
Merged
Conversation
Token names were checked for clashes only within one kind, so a color `card` and a shadow `card` both declared `--card` and one silently replaced the other in `:root`. Deserializing the theme now checks colors, `length` and `shadow` together and reports the two tokens and the variable. The atom identity fixture that gave a length and a shadow the same name now names the shadow `lift`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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
NEW-04: token names were checked for clashes only within one kind (
check_token_names/flatten_color_value). A colorcardand a shadowcardtherefore both declared--card, and whichever came last in:rootsilently replaced the other.Themenow uses serde'sremote = "Self"pattern. The derived field-by-field deserialization stays as it was, and the traitDeserializeimpl then runscheck_token_kindsover the whole theme. Every path that reads a theme gets the check: the wasm and napiregisterThemedecode, andserde_json.check_token_kindscompares the CSS variables of colors (every variant,css_key),lengthandshadow(css_key_from, sogray.100andgray-100are the same variable). The same name in two variants of one kind is still allowed, because it is the same variable on purpose.first_value.rsgave a length and a shadow the same namespace, which is exactly this clash. The shadow is now calledlift. The assertions still check that a shadow token's first value resolves on its own.New build error:
theme: color token 'card' and shadow token 'card' both become the CSS variable --card: rename oneRefs #685
Test plan
cargo test -p sheet --lib(234 passed)cargo clippy -p sheet --all-targets -- -D warnings,cargo fmt --all -- --checkapps/landing/devup.jsonchecked for cross-kind clashes (none)🤖 Generated with Claude Code