fix(linter): support grouped color tokens#68
Conversation
|
Added one final hardening commit after a deeper edge-case audit. The update adds collision detection for cases where a grouped color token would flatten into an already-defined token name, for example: colors:
utility-info-50: "#111111"
utility-info:
50: "#222222"This now emits a clear lint diagnostic instead of silently overwriting one value. I also added tests for collision handling and invalid grouped color values such as booleans, arrays, and bare numbers. Validation:
Note: the root Turbo build still appears blocked by the existing missing root |
|
Hey @Arshgill01. Thank you for taking the time. We are currently working out the syntax and behavior, tracking in #66. We need to land that first before we can finalize the implementation. Let me ping you when we have a solution. |
|
Hey @Arshgill01, thank you for the work here, especially the collision detection logic and the edge case audit. Nested token support landed in v0.3.0 via PR #103. That PR added a generic colors:
utility-info:
50: "#EEF7FC"
100: "#D4EBF7"are now parsed as One thing your PR has that #103 does not: collision detection for cases where a flat key and a grouped key produce the same name. That's a good idea and worth tracking. If you're interested, filing a separate issue for collision detection would be welcome and we can work on it from there. Create an issue and tag me in it. Going to close this since the nesting support is already on main. Thank you for the contribution. |
|
@davideast — following up here. Filed the issue you suggested (#149) and opened a PR implementing both collision cases (duplicate dot path + flat/grouped name normalization) across |
Summary
Adds support for nested color groups under
colorswhile preserving the existing flat color-token behavior.This allows DESIGN.md files to define color scales like:
instead of requiring all tokens to be manually flattened:
What changed
Added a recursive
ParsedColorValuetype for parsed color values.Updated parser/model typing to allow nested color groups without falling back to
any.Added grouped color flattening in the model layer.
Preserved flat token keys such as
utility-info-50.Added symbol-table support for both:
{colors.utility-info-50}{colors.utility-info.50}Updated the DESIGN.md spec documentation for grouped color tokens.
Added tests for grouped color parsing, invalid nested color diagnostics, component references, Tailwind export, and DTCG export.
Behavior
Grouped color input:
is normalized internally/exported as:
This keeps Tailwind-friendly output while still allowing object-path token references.
Validation
bun installbun testbun run buildfrompackages/cliResult: all 239 tests pass and the package builds successfully.
Notes
DTCG and Tailwind exports intentionally preserve flattened token names such as
utility-info-50. This avoids data loss and maintains compatibility with the existing flat color-token model.Fixes #66.