Conversation
@wordpress/use-recommended-components
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
There was a problem hiding this comment.
This seems redundant to the setup we already have with tools/eslint-excludelist.json and use of @automattic/eslint-changed.
OTOH, even better is to actually fix problems when introducing a new sniff. 😉
| wordpressEslintPlugin.configs.i18n, | ||
| { | ||
| rules: { | ||
| '@wordpress/use-recommended-components': 'error', |
There was a problem hiding this comment.
It would probably make more sense to move this down to the base rules section, near
jetpack/tools/js-tools/eslintrc/base.mjs
Lines 283 to 292 in 482b6b5
| }, | ||
| }, | ||
|
|
||
| // .cjs files are always Node.js scripts — add Node.js globals too. |
tbradsha
left a comment
There was a problem hiding this comment.
I haven't done a deep code review, but any reason we're not just cleaning these up directly? Looks like ~250 instances in the suppressions file, and I suspect many of them are the same or similar instances. Could one throw AI at it?
I'd at least recommend trying a cleanup of violations/merge into trunk before adding this.
Also, if I'm skimming correctly, it seems that once a file has suppressed errors of the given type, it won't prevent additional such errors from being added to a file.
My fear is that we'll end up with an additional layer of complexity that only serves to suppress issues we haven't properly fixed.
That's not trivial as these aren't mere code-formatting lints; code change would be simple'ish, but each component swap usually needs some design decisions and, of course, lots of testing that things continue working, which is a lot of work. There are four folks replacing old components right now with Note that Gutenberg is using an identical strategy to change their components. |
We definitely appreciate the cleanup/modernization efforts! I totally get this, having dealt with Phan cleanup (which uses baselines) and Stylelint (no baselines but rule-by-rule cleanup). We have the same goal, so let's see if we can align on implementation. :^) Some thoughts:
|
|
As an aside, it seems If it's noise/interfering with your current work, feel free to close it. 😄 I also notice you put up a similar PR targeting just Forms here: #48407 |
|
Feel free to open an issue in Gutenberg to discuss / agree on improvements to |
Added here: WordPress/gutenberg#78062 |
Likely best done after #48405 and #48404 land (which updates UI and Eslint libraries)
Proposed changes
Upgrade
@wordpress/eslint-pluginfrom25.0.0→25.1.0. The new version ships a more completeuse-recommended-componentsrule that flags additional deprecated@wordpress/componentsexports (__experimentalHStack,__experimentalVStack,__experimentalText,Card,VisuallyHidden,ExternalLink, etc.) and recommends@wordpress/uialternatives.Enable
@wordpress/use-recommended-componentsas anerror-level ESLint rule monorepo-wide (intools/js-tools/eslintrc/base.mjs). This encourages migration away from deprecated/experimental@wordpress/componentsexports toward stable@wordpress/uicomponents.Introduce a bulk-suppressions workflow (adapted from WordPress/gutenberg) to avoid scattering hundreds of
// eslint-disablecomments across existing files:tools/eslint/lint-js.cjs— ESLint wrapper that auto-injects--suppressions-location tools/eslint/suppressions.jsoninto every lint run. It also detects when suppressions become stale and prints a hint to runpnpm run lint:js:prune-suppressions.tools/eslint/suppressions.json— Central file cataloguing all pre-existing violations by file path and count. New violations are caught as errors; existing ones are suppressed here.lint-filescript to use the wrapper.lint:js:update-suppressionsandlint:js:prune-suppressionshelper scripts.Fix ESLint config:
.cjsfiles now correctly receiveglobals.node(addsprocess,Buffer, etc.) in addition to the existingglobals.commonjs. Previously Node.js globals were missing for CommonJS scripts outside of config-file patterns.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Verify the rule is active:
ExternalLinkfrom@wordpress/components— ESLint should report an error: "UseLinkfrom@wordpress/uiwith theopenInNewTabprop instead."tools/eslint/suppressions.json(e.g.projects/js-packages/components/components/admin-page/index.tsx) — the existing violation should be silently suppressed andpnpm run lint-file <file>should exit 0.Verify the suppression workflow: