ESLint: Add use-import-as rule#77389
Conversation
|
Size Change: 0 B Total Size: 7.76 MB ℹ️ View Unchanged
|
|
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. |
|
Flaky tests detected in 43cdffb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24833217145
|
ciampo
left a comment
There was a problem hiding this comment.
-
Should we add a CHANGELOG entry for the
@wordpress/eslint-pluginpackage? -
Should we update all docs in
@wordpress/componentsto also use the suggested renaming in Gutenberg? Or at least, should we remove the__experimentalComponent as Componentpattern in those docs?
Left a few suggestions, some of them being the result of an internal AI-assisted review.
# Conflicts: # packages/eslint-plugin/CHANGELOG.md
Added.
I'm a bit hesitant to do that right now because the actual value mapping is only defined in every repo's own eslintrc. |
ciampo
left a comment
There was a problem hiding this comment.
LGTM 🚀
Left some extra feedback, but pre-approving
| { | ||
| '@wordpress/components': { | ||
| __experimentalText: 'WCText', | ||
| Badge: 'WCBadge', | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Should we also add `VisuallyHidden: 'WCVisuallyHidden', ?
There was a problem hiding this comment.
I'm cleaning up everything in #77575, so not needed.
What?
Part of #76135
@wordpress/use-import-asrule to@wordpress/eslint-plugin.@wordpress/componentsaliases, including__experimentalText->WCTextandBadge->WCBadge.Why?
As we introduce new components from
@wordpress/ui, there will be equivalent components from@wordpress/componentsthat have the same name. This makes it easier to distinguish between the two, both for a human eye and when grepping.How?
use-import-asESLint rule that accepts a package-to-name mapping in config.const { Badge } = unlock( privateApis );destructuring pattern for private APIs.WCTextandWCBadgealiases where applicable.Testing Instructions
wp-scripts test-unit-js --config test/unit/jest.config.js packages/eslint-plugin/rules/__tests__/use-import-as.js --runInBand.wp-scripts lint-js --config eslint.config.mjs packages --rule "@wordpress/use-import-as:error".@wordpress/use-import-aserrors.Use of AI Tools
Cursor AI was used to help implement the ESLint rule, update existing usages, and prepare this pull request. I reviewed and validated the resulting changes.