Skip to content

Stylelint: Flag the gutenberg-base-styles wrapper where @wordpress/base-styles is declared - #54348

Closed
xavier-lc wants to merge 2 commits into
trunkfrom
update/stylelint-no-base-styles-wrapper
Closed

xavier-lc wants to merge 2 commits into
trunkfrom
update/stylelint-no-base-styles-wrapper

Conversation

@xavier-lc

@xavier-lc xavier-lc commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Part of JETPACK-2754

The sweep (#54281–#54289) replaced @automattic/jetpack-base-styles/gutenberg-base-styles with direct @wordpress/base-styles/<module> imports in every project that declares @wordpress/base-styles. This rule keeps the wrapper from coming back there.

Proposed changes

  • Add a local stylelint rule, jetpack/no-redundant-base-styles-wrapper, enabled in the shared base config. It reports @use, @forward and @import of the wrapper when any package.json between the file and its project root (the directory with composer.json) declares @wordpress/base-styles. Nested ones such as wp-build routes/* list no dependencies, so it checks all of them.
  • Projects that don't declare the dependency (js-packages/components, js-packages/shared-extension-utils, packages/external-media) still rely on the wrapper, and the rule doesn't fire there.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • tools/js-tools/node_modules/.bin/stylelint 'projects/**/*.{scss,css}' reports nothing for the new rule on trunk's current styles.
  • Add @use "@automattic/jetpack-base-styles/gutenberg-base-styles" as gb; to an SCSS file in projects/packages/my-jetpack, both under _inc/ and under routes/dashboard/, and run stylelint on it: the rule reports both.
  • Add the same line to a file in projects/js-packages/components: no report.

🤖 Generated with Claude Code

…se-styles is declared

Add a local jetpack/no-redundant-base-styles-wrapper rule that reports
@use, @forward and @import of @automattic/jetpack-base-styles/gutenberg-base-styles
in files whose nearest package.json declares @wordpress/base-styles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K4t4VY7ojGc1sr9Cb1z84Z
@xavier-lc xavier-lc added [Status] Needs Review This PR is ready for review. [Type] Janitorial labels Oct 30, 2026
@xavier-lc
xavier-lc requested a review from a team as a code owner October 30, 2026 10:32
@xavier-lc xavier-lc self-assigned this Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@xavier-lc
xavier-lc marked this pull request as draft October 30, 2026 10:39
Nested package.json files (wp-build routes, packages/init) list no
dependencies, so stopping at the nearest one skipped every stylesheet
under them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K4t4VY7ojGc1sr9Cb1z84Z
@xavier-lc
xavier-lc marked this pull request as ready for review October 30, 2026 10:42
@xavier-lc
xavier-lc requested a review from CGastrell October 30, 2026 10:43

@anomiex anomiex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easier to get rid of the final few uses of the wrapper entirely and then delete it, instead of adding a linting rule?

@xavier-lc

Copy link
Copy Markdown
Contributor Author

Would it be easier to get rid of the final few uses of the wrapper entirely and then delete it, instead of adding a linting rule?

The linear issue says to not touch the wrapper on the projects that get the mixins without taking on the dependency. And in any case, I think that it can be good to have the rule against future regressions. Wdyt?

@anomiex

anomiex commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

The Linear issue does say that, but it doesn't say why. Maybe it just didn't consider taking it far enough? Or maybe it didn't realize how few uses would be left?

If we get rid of the wrapper entirely, that would also prevent regressions because the code would fail on trying to load the missing wrapper. 😀

@anomiex

anomiex commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

At second glance, more specifically it says (emphasis added)

Where it does not, leave it alone, or decide separately whether the project should declare the dependency.

Let's decide "yes" because there are only three projects left, may as well make a complete job of it.

I further note that in two of those projects the only uses of @automattic/jetpack-base-styles are the wrapper, so switching to the direct dep should let us drop the @automattic/jetpack-base-styles from them entirely.

@xavier-lc

Copy link
Copy Markdown
Contributor Author

Agreed, done that way instead:

Closing this one.

@xavier-lc xavier-lc closed this Nov 2, 2026
@xavier-lc
xavier-lc deleted the update/stylelint-no-base-styles-wrapper branch November 2, 2026 09:05
@github-actions github-actions Bot removed [Status] In Progress [Status] Needs Review This PR is ready for review. labels Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants