Refactor: move stylelint config and deps to tools/stylelint workspace#79226
Conversation
|
checking what is causing storybook to break |
manzoorwanijk
left a comment
There was a problem hiding this comment.
This looks great. One minor suggestion for further improvement.
manzoorwanijk
left a comment
There was a problem hiding this comment.
Thanks. This looks great.
|
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. |
| 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' ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Thank you for the context. Please go ahead.
There was a problem hiding this comment.
Heh, wasn't aware of that existing issue, thanks for finding and sharing it! It's good reassurance that this would be an improvement.
What?
Related to #75041
Moves the root
.stylelintrc.jsconfiguration and itsstylelint-plugin-logical-cssdependency into a newtools/stylelintworkspace package (@wordpress/stylelint-tools), following the same pattern used by@wordpress/eslint-tools.Why?
Keeps root
package.jsonlean and aligns with thetools/eslint/workspace pattern.How?
tools/stylelint/workspace with@wordpress/stylelint-toolspackage exporting./config..stylelintrc.js→tools/stylelint/config.js; root gets a thin.stylelintrc.mjswrapper.stylelint-plugin-logical-cssfrom root deps; sub-packages reference config via workspace name.wp-scripts lint-styleto detect.cjs/.mjsconfig files.Testing Instructions
npm installto link the new workspace.npm run lint:css— verify same lint results as ontrunk(no new warnings/errors).npm run lint:cssdetects.stylelintrc.mjsautomatically (no--configflag needed).npm run test:unit packages/stylelint-config/test/..scssfile and confirmwp-scripts lint-stylepicks 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.