Fix component naming and hook wrapper lint errors#77003
Conversation
Fix react/display-name and react-hooks/rules-of-hooks violations by naming anonymous components and renaming deprecated hook wrappers: - Name anonymous arrow function exports (BlockCrashWarning, ToolbarButtonContainer, WithFocusOutside) - Rename __experimental hook wrappers to use valid hook names (useDeprecated*) and re-export with the original prefixed name No behavior change — all public APIs remain identical.
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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. |
|
Moving this to #77002 |
|
Merged into #77002 instead. |
|
Size Change: +5 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 0161361. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23903367458
|
What?
Closes part of #76506
Fixes
react/display-nameandreact-hooks/rules-of-hookslint violations by making code changes instead of adding eslint-disable comments.Why?
Extracting these fixes from the main ESLint v10 upgrade PR (#76654) to reduce its diff size. All changes are backward-compatible with ESLint v8.
How?
Named function exports (fixes
react/display-name)Anonymous arrow function component exports lack a
displayName, which makes debugging harder. Converted to named function declarations:block-crash-warning.js/.native.js:() => warning→function BlockCrashWarning()toolbar-button-container.native.js:( props ) => <View>...→function ToolbarButtonContainer( props )with-focus-outside/index.native.js:( props ) => {→function WithFocusOutside( props ) {Hook wrapper renames (fixes
react-hooks/rules-of-hooks)Deprecated
__experimental*hook wrappers have names that don't match theuse*convention, sorules-of-hooksflags hook calls inside them as violations. Renamed the internal function touseDeprecated*and re-exported with the original prefixed name:useDeprecatedEntityRecordas__experimentalUseEntityRecorduseDeprecatedResourcePermissionsas__experimentalUseResourcePermissionsNo behavior change — all public APIs remain identical.
Testing Instructions
npm run lint:js— no new errorsnpm run test:unit -- packages/core-data— all tests passTesting Instructions for Keyboard
N/A — no UI changes.
Screenshots or screencast
N/A — code cleanup only.