Repository navigation
Bump @wordpress/theme to 1.0.0 and migrate WPDS token names - #14
Merged
Merged
Conversation
The repo pinned @wordpress/theme 0.13.0, which defines the old short-form colour token names. Upstream renamed the bg and fg groups to background and foreground in 0.16.0, so every --wpds-color-bg-* and --wpds-color-fg-* reference here stops resolving on 1.0.0 and silently drops to its fallback. Rename all five affected tokens in the top menu and footer partials, and collapse the three var(--short, var(--long, #hex)) declarations the footer used to straddle both versions. While in there, correct six hardcoded fallbacks in the top menu partial that were already wrong against 0.13.0, not just against 1.0.0: padding-xl fell back to 16px where the token is 20px, fg-content-neutral to #1d2327 where it is #1e1e1e (the same token elsewhere in the file already used #1e1e1e), fg-content-neutral-weak to #6d6d6d where it is #707070, and stroke-interactive-neutral-strong to #6c6c6c where it is #6e6e6e. They were inert because the tokens resolve, but they are what the UI would fall back to if the token stylesheet ever stopped being inlined. Two borders change appearance. --wpds-color-stroke-surface-neutral-weak went from #e4e4e4 to #f0f0f0 in 0.15.0, when the stroke1 contrast target was raised from 2.6 to 2.9. That token draws the top menu's bottom border and the footer's top border, so both lighten. Resolving every declaration in both partials against each version's token table confirms those two are the only rendered changes.
This was referenced Jul 28, 2026
Contributor
Author
Follow-ups opened:
Neither blocks this PR. |
The previous commit corrected six hardcoded fallbacks by hand, and found the rename it migrated by reading the diff. Both of those checks can be made against the token table @wordpress/theme already ships, so lint them instead. Add stylelint with two of the package's own rules. no-unknown-ds-tokens rejects --wpds-* names that do not exist in the installed version, which is what would have caught the bg and fg rename. no-token-fallback-values keeps hardcoded fallbacks out of var(). Drop all 25 fallbacks from the two emerald partials. None of them could ever be reached: _jpcrm_top_menu.scss imports design-tokens.css into the same compiled stylesheet that references it, so every token resolves from the :root block in that file. Six had silently drifted out of sync, which is the argument against keeping them around. The compiled CSS differs from the previous build only by the removed fallbacks. The 167-token :root table is unchanged, so nothing renders differently, and all four emerald variants resolve their 15 references with none left undefined. The config does not extend a style guide, deliberately. The Sass sources predate any linting and a full rule set would bury the two token rules under thousands of pre-existing formatting errors. Run it with make lint-css. It is not a prerequisite of make build yet, because that target is shared with other plugins that have no stylelint config, and making it portable needs more thought than this PR should carry.
This was referenced Jul 28, 2026
This was referenced Aug 11, 2026
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.
Fixes #13
Summary
The repo pinned
@wordpress/theme0.13.0, which defines the old short-form colour token names. Upstream renamed thebgandfggroups tobackgroundandforegroundin 0.16.0, so every--wpds-color-bg-*and--wpds-color-fg-*reference here stops resolving on 1.0.0 and silently drops to its hardcoded fallback. This bumps the package and migrates the names.Five tokens are affected, across the top menu and footer partials. None of them changed value in the rename, so the migration on its own is visually inert. What does change is one unrelated token, covered below.
A second commit follows up on that. Both of the checks the first commit relied on, spotting the rename and catching the drifted fallbacks, were done by reading the diff, and both are decidable against the token table the package already ships. So the second commit adds stylelint with two of the package's own rules and drops the hardcoded fallbacks entirely.
Changes
First commit, the migration:
package.jsonand the lockfile:@wordpress/theme0.13.0 to 1.0.0.sass/emerald/_jpcrm_top_menu.scss: rename the five short-form tokens, and correct six hardcoded fallbacks.sass/emerald/_jpcrm_footer.scss: rename, and collapse the threevar(--short, var(--long, #hex))declarations that CRM: Align admin footer with the unified Jetpack footer #8 added to straddle both versions. They have done their job now.Second commit, the lint:
stylelint.config.mjs, new:plugin-wpds/no-unknown-ds-tokensandplugin-wpds/no-token-fallback-values.package.jsonand the lockfile:stylelint16.26.1 andpostcss-scss4.0.9, both dev only, and alint:cssscript.Makefile: alint-csstarget.The stale fallbacks
Six fallbacks in the top menu partial were already wrong against 0.13.0, not just against 1.0.0:
--wpds-dimension-padding-xl16px20px--wpds-color-fg-content-neutral#1d2327#1e1e1e--wpds-color-fg-content-neutral-weak(x2)#6d6d6d#707070--wpds-color-stroke-surface-neutral-weak#dcdcde#f0f0f0--wpds-color-stroke-interactive-neutral-strong#6c6c6c#6e6e6eThey were inert, because the tokens resolve. But they are what the UI would land on if the token stylesheet ever stopped being inlined, and the same token appeared elsewhere in the file with the correct
#1e1e1e, so it was inconsistent with itself.The first commit corrected them. The second removes them, along with the other nineteen, for the reason below.
The one visible change
--wpds-color-stroke-surface-neutral-weakwent from#e4e4e4to#f0f0f0in 0.15.0, when thestroke1contrast target was raised from 2.6 to 2.9. That token draws two things here, so both lighten:I resolved every declaration in both partials against each version's token table and diffed the results. Those two borders are the only rendered changes in the whole bump.
Dropping the fallbacks
None of the 25 fallbacks could ever be reached.
_jpcrm_top_menu.scss:1importsdesign-tokens.css, and both partials compile into the samecss/jpcrm-emerald.css, so the whole token table is present at:rootin the same file that references it. Everyvar()resolves and the fallback is dead.They do not help against another plugin either, which was my first thought. A plugin on a pre-0.16
@wordpress/themedefines the short names, which we no longer reference, so there is no collision. A plugin on 1.x defines the same long names at:root, and last loaded wins, but the token is then defined andvar()resolves to its value, so the fallback is bypassed anyway. A custom property can only be overwritten with a value, never un-defined, which routes around the fallback by definition.What they did do was rot quietly. Six of the 25 had drifted out of sync with no visible symptom, and I only found them by hand. That is the argument for the lint rather than the fallback: an unknown token now fails the build-time check loudly instead of falling back to a stale value at runtime.
Upstream's own rule message says fallbacks "should be injected automatically at build time" via
postcss-ds-token-fallbacks. We do not need that while the token table is inlined into the same stylesheet. It would matter if we ever move thedesign-tokens.cssimport somewhere less global, which is the same refactor as the issue below.The lint
Two rules, both shipped by
@wordpress/themeitself:no-unknown-ds-tokensrejects--wpds-*names that do not exist in the installed version. This is the rule that would have caught the wholebgandfgrename automatically.no-token-fallback-valueskeeps hardcoded fallbacks out ofvar().The config deliberately does not extend a style guide. The Sass sources predate any linting and a full rule set would bury these two under thousands of pre-existing formatting errors.
postcss-scssis not optional, the default CSS parser chokes on//comments and@use.Run it with
make lint-css, ornpm run lint:css.It is not a prerequisite of
make buildyet, which is where it would actually earn its keep, since a release always runs that target. The Makefile is shared with other plugins and adding the prerequisite would breakmake buildin any of them that has no stylelint config. Making that portable needs more thought than this PR should carry, so it goes in its own PR.A side effect worth knowing about
WordPress core injects an inline
@layer wp-ui-componentsblock for its badge component. It references short-form WPDS names with its own fallbacks. Because our stylesheet publishes the entire token table into a global:root, we were overriding core's badge tokens with our package's values. Six of them differed:bg-surface-neutral#f8f8f8#fcfcfcbg-surface-neutral-weak#f0f0f0#f4f4f4fg-content-neutral-weak#6d6d6d#707070bg-surface-success#c5f7cc#c6f7cdbg-surface-warning#fde6bd#fde6bebg-surface-caution#fee994#fee995After the bump those short names no longer exist, so core's badges get their intended values back. The differences are 1 to 4 units and no such badges render on CRM pages today, so nothing is visibly different. The direction is right though, and it makes the case for moving the
design-tokens.cssimport somewhere more deliberate. Publishing a global:rootblock means we theme anything on the page that speaks WPDS, which is not what we want. I'll open a separate issue for that.Testing
Verified on a live install, on the CRM dashboard and a contact record:
The check that matters:
--wpds-color-bg-surface-neutraland--wpds-color-fg-content-neutralare now undefined on the page, while their long-form counterparts resolve. That confirms the rename was load-bearing. Without this migration those declarations would have quietly fallen back.Also:
--wpds-*reference in the loadedjpcrm-emerald.cssagainst:rooton both pages. Zero undefined.var(--wpds-*)references in the Sass sources against 1.0.0'sdesign-tokens.css, for both name and fallback value. All match.var()straddles remain in the Sass sources.npm run buildcompiles clean. The compiled output inlines 188 token definitions, none short-form.margin: 0from the 782px rule, without triggering the 480px stacking. As intended.For the second commit:
no-token-fallback-valuesflagged exactly 25 problems, matching the 25 known references.no-unknown-ds-tokensreports nothing on the current source, so I checked it against a throwaway file: it rejects--wpds-color-fg-content-neutraland passes the long-form name. That is the rename it needs to catch.:roottable is identical, so nothing renders differently, and the live values above still hold.make lint-cssexits 2 on a bad token and 0 once it is removed.I didn't attach before and after screenshots. The only rendered difference is
#e4e4e4to#f0f0f0on two 1px borders, so the pair would look identical. The computed values above are the better evidence.Note on the lockfile
The lockfile is up 1183 lines against trunk for two version changes, and it is all dev weight.
892 of those come from stylelint and its 63 packages. The rest is
@wordpress/theme1.0.0 pulling in 22 transitive packages (@wordpress/compose,@wordpress/i18n,tannin,mousetrapand friends) as dependencies of theThemeProviderReact component it now ships. Nothing here imports it, only the CSS file, so none of that reaches the bundle. The lock has zero non-dev packages in it at all, and the root has no runtime dependencies.stylelint.config.mjsis a new top-level file, andship_pathsinscripts/build-plugin.shis an explicit allow-list, so it stays out of the release zip.Follow-ups
lint-cssa prerequisite ofmake build, in a way that survives the Makefile being copied to plugins without a stylelint config.create-release.yml:41runs a barenpm installwith noactions/setup-nodeand there is no.nvmrc. 1.0.0 requires^20.19.0 || >=22.13.0and is ESM only, and stylelint now runs in that same path. Also shared tooling, so it belongs with the item above.design-tokens.cssimport somewhere less global, per the badge section.