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 2614c86. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24515114123
|
ciampo
left a comment
There was a problem hiding this comment.
Overall, LGTM 🚀
Flagging two scenarios in which the rule won't flag an error:
- Namespaced imports (ie.
import * as ui from '@wordpress/ui'; [...] <ui.Link render={ <ui.Text /> }>), although this usecase is rare enough that it can be ignored; - Non-
JSXElementrender prop (ierender={ createElement( VisuallyHidden ) }or conditional/fragment wrappers)
Not sure how easy it would be to match those edge cases, but we could at least document and acknowledge the limitation.
| | [no-dom-globals-in-react-fc](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-dom-globals-in-react-fc.md) | Disallow use of DOM globals in the render cycle of a React function component. | | | ||
| | [components-no-missing-40px-size-prop](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/components-no-missing-40px-size-prop.md) | Disallow missing `__next40pxDefaultSize` prop on `@wordpress/components` components. | ✓ | | ||
| | [components-no-unsafe-button-disabled](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/components-no-unsafe-button-disabled.md) | Disallow using `disabled` on Button without `accessibleWhenDisabled`. | ✓ | | ||
| | [no-unsafe-render-order](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-render-order.md) | Prevent unsafe `render` composition orders that silently remove semantics. | | |
There was a problem hiding this comment.
I guess the new rule should be marked as recommended also in the README?
| | [no-unsafe-render-order](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-render-order.md) | Prevent unsafe `render` composition orders that silently remove semantics. | | | |
| | [no-unsafe-render-order](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-render-order.md) | Prevent unsafe `render` composition orders that silently remove semantics. | ✓ | |
What?
Follow up to #77190
no-unsafe-render-orderESLint rule for theVisuallyHiddenandLink/Textrender-prop footgunsVisuallyHiddenandLinkguidance to only recommend the safe composition directionThis rule will be enabled in the recommended set of lint rules in the wordpress eslint package.
Why?
These composition pitfalls are easy to miss because the UI can still look correct while the underlying element semantics change. A focused lint rule makes the safe direction explicit and helps keep the documentation aligned with that guidance.
How?
render={ <VisuallyHidden /> }whenVisuallyHiddenis imported as a named importLink render={ <Text /> }whenLinkandTextare imported as named importspackages/uiviacheckLocalImportsTesting Instructions
./node_modules/.bin/eslint packages/eslint-plugin/rules/no-unsafe-render-order.js packages/eslint-plugin/rules/__tests__/no-unsafe-render-order.js eslint.config.mjs packages/ui/src/visually-hidden/visually-hidden.tsx packages/ui/src/link/stories/index.story.tsx../node_modules/.bin/jest packages/eslint-plugin/rules/__tests__/no-unsafe-render-order.js --runInBand.<Dialog.Title render={ <VisuallyHidden /> }>and<Link render={ <Text /> }>but does not report<VisuallyHidden render={ <Dialog.Title /> }>.