Repository navigation
Stylelint: extract the shared rule set into a reusable "project" preset - #81369
Draft
i-am-chitti wants to merge 2 commits into
Draft
i-am-chitti wants to merge 2 commits into
i-am-chitti wants to merge 2 commits into
Conversation
This branch has not been deployed
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?
Closes #81349
Adds a
projectpreset to@wordpress/stylelint-configholding the Stylelint rules Gutenberg and WordPress Core share, and switchestools/stylelint/config.jsover to it so the set has a single source.Why?
wordpress-develop#12934 proposes adding Stylelint to Core, and its
.stylelintrc.jsis currently a copy of Gutenberg's config. The overlap is exact: Core's file is tools/stylelint/config.js minus declaration-property-value-disallowed-list, plugin-wpds/no-token-fallback-values and the overrides section — the other ~22 rules and bothreport*Disablesoptions are identical. Keeping two copies in sync by hand is the maintenance problem the issue describes.How?
The shared set becomes a fourth preset in the already-published
@wordpress/stylelint-config, alongsidescss/stylistic/scss-stylistic, rather than a new package. It extendsscss-stylisticand carries the shared rules plusreportNeedlessDisablesandreportDescriptionlessDisables.tools/stylelint/config.jsdrops from 173 to 122 lines and keeps only Gutenberg's own configuration:Core's config then becomes
extends: '@wordpress/stylelint-config/project'plus itsignorePath.Two incidental cleanups fall out: the file was re-registering the
no-token-fallback-valuesplugin and re-enabling its rule, both already no-ops given the base config, andtools/stylelintno longer needs its@wordpress/themedependency.Note for reviewers:
plugin-wpds/no-token-fallback-valuesis excluded from the extracted set per the issue, but that does not actually keep it out of Core — it is enabled in the base index.js that Core already extends, along withno-unknown-ds-tokensandno-setting-wpds-custom-properties. They are inert there (Core has no--wpds-*tokens), so this PR leaves the base preset alone; excluding WPDS rules from Core entirely would be a separate, more disruptive change.Testing Instructions
This is a no-op refactor for Gutenberg — the goal is proving the resolved config did not change.
npm run lint:cssnpm run test:unit packages/stylelint-confignpx stylelint --print-config <file>on this branch againsttrunkfor each file shape in the repo:packages/components/src/button/style.scss(plain SCSS)packages/components/src/angle-picker-control/style.module.scss(CSS module, SCSS)widgets/hello-world/style.module.css(CSS module, CSS)routes/template-list/style.scss(routes/)Output is semantically identical for all four; only key ordering shifts, so sort keys before diffing.
Testing Instructions for Keyboard
N/A — build tooling only, no UI changes.
Use of AI
Claude Code Opus 5
Purpose - compare configs, extract shared rules, verify equivalence, write tests