Theme: Enrich design-tokens.js export with token metadata#76604
Draft
Theme: Enrich design-tokens.js export with token metadata#76604
design-tokens.js export with token metadata#76604Conversation
dac0b1b to
67dcbaf
Compare
|
Size Change: 0 B Total Size: 8.75 MB ℹ️ View Unchanged
|
Replace the flat array default export with two named exports: `tokens` (keyed by variable name, with description and group) and `groups` (keyed by source file, listing member tokens). Update ESLint and Stylelint consumers accordingly.
The Terrazzo iteration order is already deterministic.
67dcbaf to
51a0f68
Compare
|
Flaky tests detected in 51a0f68. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23220683044
|
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.
What?
Replaces the flat
string[]default export of@wordpress/theme/design-tokens.jswith two named exports:tokens— an object keyed by CSS variable name, withdescriptionandgroupmetadata for each token.groups— an object keyed by group name (derived from the source token file), with an array of member token names as values.Why?
The previous export was a flat list of CSS variable names used only for lint rule validation. Storybook stories and documentation that need to display token metadata (descriptions, groupings) currently hardcode this information, which can drift from the source of truth in
tokens/*.json.By exposing the metadata that the Terrazzo build already has access to, consumers like stories and docs can stay in sync without duplication.
How?
terrazzo-plugin-known-wpds-css-variablesTerrazzo plugin to read$descriptionand source file location from the token data (same approach used by the existing docs plugin) and output the two named exports.packages/eslint-plugin/rules/no-unknown-ds-tokens.js— switched fromnew Set(tokenList)tonew Set(Object.keys(tokenMap)).packages/theme/src/stylelint-plugins/no-unknown-ds-tokens.mjs— same change.Testing Instructions
Run the ESLint and Stylelint rule tests:
Use of AI Tools
Authored with Cursor (Claude).