Theme: Add no-token-fallback-values stylelint rule#76415
Conversation
|
Size Change: 0 B Total Size: 8.75 MB ℹ️ View Unchanged
|
168179d to
94a858c
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 74ec5ce. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23209966517
|
ciampo
left a comment
There was a problem hiding this comment.
Nice refactor! LGTM 🚀
Enabled in the root .stylelintrc.js only (not in @wordpress/stylelint-config) to avoid imposing it on external consumers of the preset.
Makes sense, as far as the new rule is easy to discover?
What?
Adds a new stylelint rule
plugin-wpds/no-token-fallback-valuesthat disallows manually authored fallback values for--wpds-*design tokens.Why?
The
addFallbackToVarPostCSS plugin in@wordpress/themealready injects fallbacks for--wpds-*tokens at build time. Manual fallbacks in source are redundant and can drift out of sync with the token definitions.This is a companion rule to that build plugin, similar to how
no-unknown-ds-tokensvalidates that tokens exist andno-setting-wpds-custom-propertiesprevents defining tokens outside of the design system.How?
packages/theme/src/stylelint-plugins/no-token-fallback-values.mjs. Uses a regex to matchvar(--wpds-<name>,patterns (the comma indicates a fallback)..stylelintrc.jsonly (not in@wordpress/stylelint-config) to avoid imposing it on external consumers of the preset.Testing Instructions
npm run test:unit -- --testPathPattern="packages/theme/src/stylelint-plugins/test"— all 15 tests across the 3 rules should pass.