Skip to content

Refactor: move stylelint config and deps to tools/stylelint workspace#79226

Merged
manzoorwanijk merged 7 commits into
WordPress:trunkfrom
USERSATOSHI:refactor/stylelint-tools-workspace
Jun 16, 2026
Merged

Refactor: move stylelint config and deps to tools/stylelint workspace#79226
manzoorwanijk merged 7 commits into
WordPress:trunkfrom
USERSATOSHI:refactor/stylelint-tools-workspace

Conversation

@USERSATOSHI

Copy link
Copy Markdown
Contributor

What?

Related to #75041

Moves the root .stylelintrc.js configuration and its stylelint-plugin-logical-css dependency into a new tools/stylelint workspace package (@wordpress/stylelint-tools), following the same pattern used by @wordpress/eslint-tools.

Why?

Keeps root package.json lean and aligns with the tools/eslint/ workspace pattern.

How?

  1. Create tools/stylelint/ workspace with @wordpress/stylelint-tools package exporting ./config.
  2. Move root .stylelintrc.jstools/stylelint/config.js; root gets a thin .stylelintrc.mjs wrapper.
  3. Remove stylelint-plugin-logical-css from root deps; sub-packages reference config via workspace name.
  4. Extend wp-scripts lint-style to detect .cjs/.mjs config files.
  5. Fix stylelint bin resolution in test utilities.

Testing Instructions

  1. Run npm install to link the new workspace.
  2. Run npm run lint:css — verify same lint results as on trunk (no new warnings/errors).
  3. Confirm npm run lint:css detects .stylelintrc.mjs automatically (no --config flag needed).
  4. Run stylelint-config tests: npm run test:unit packages/stylelint-config/test/.
  5. Verify lint-staged still works: stage a .scss file and confirm wp-scripts lint-style picks up the right config.

Use of AI Tools

AI tooling deepseek v4 flash free was used for code exploration and locating all files affected by this refactor.

All changes have been manually reviewed and verified by me.

@github-actions github-actions Bot added [Package] Components /packages/components [Package] Block library /packages/block-library [Package] Theme /packages/theme labels Jun 16, 2026
@USERSATOSHI

Copy link
Copy Markdown
Contributor Author

checking what is causing storybook to break

@manzoorwanijk manzoorwanijk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great. One minor suggestion for further improvement.

Comment thread .stylelintrc.mjs Outdated
@manzoorwanijk

Copy link
Copy Markdown
Member

Storybook failure was caused by #79003 and is being reverted in #79243

@manzoorwanijk manzoorwanijk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. This looks great.

@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Jun 16, 2026
@manzoorwanijk manzoorwanijk marked this pull request as ready for review June 16, 2026 14:55
@github-actions

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: USERSATOSHI <tusharbharti@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@manzoorwanijk manzoorwanijk enabled auto-merge (squash) June 16, 2026 14:57
@manzoorwanijk manzoorwanijk merged commit cccd656 into WordPress:trunk Jun 16, 2026
55 of 57 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 16, 2026
Comment on lines 26 to 36
hasProjectFile( '.stylelintrc.js' ) ||
hasProjectFile( '.stylelintrc.cjs' ) ||
hasProjectFile( '.stylelintrc.mjs' ) ||
hasProjectFile( '.stylelintrc.json' ) ||
hasProjectFile( '.stylelintrc.yaml' ) ||
hasProjectFile( '.stylelintrc.yml' ) ||
hasProjectFile( 'stylelint.config.js' ) ||
hasProjectFile( 'stylelint.config.cjs' ) ||
hasProjectFile( 'stylelint.config.mjs' ) ||
hasProjectFile( '.stylelintrc' ) ||
hasPackageProp( 'stylelint' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we should be using Stylelint's actual resolution behavior via its resolveConfig export or the cosmiconfig library it's using, rather than trying to maintain this list ourselves and keep it in sync. Case in point: it still doesn't capture all of the supported extensions, such .ts, and trying to chase all these down feels like a losing battle.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That will be great.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, I checked and cosmiconfig is already in gutenbeg root node_modules since it is a transitive dep

We can add the dependency to @wordpress/scripts and use it there.

I also came across #30842 and a stale PR that was eventually closed: #53911.

After reviewing both, it seems that integrating this approach was considered acceptable. If we decide to move forward with it, I can work on adding the implementation.

cc: @manzoorwanijk @aduth

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the context. Please go ahead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Heh, wasn't aware of that existing issue, thanks for finding and sharing it! It's good reassurance that this would be an improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library [Package] Components /packages/components [Package] Theme /packages/theme [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants