Fix pre-existing lint errors across the codebase#77002
Fix pre-existing lint errors across the codebase#77002manzoorwanijk wants to merge 7 commits intotrunkfrom
Conversation
- Convert Playwright assertions to web-first patterns (toHaveAttribute) to satisfy playwright/prefer-web-first-assertions - Trim trailing spaces in Playwright test titles (playwright/valid-title)
|
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. |
|
Size Change: +5 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
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.
Same pattern as the previous commit — rename __experimental/__unstable hook wrappers to use valid hook names and re-export with the original prefixed alias: - useDeprecatedEntityRecords as __experimentalUseEntityRecords - useDeprecatedRichText as __unstableUseRichText
Rename the function to RichTextInputEvent (valid component name) and re-export with the __unstable prefix alias. This removes the need for rules-of-hooks suppressions since hooks inside a properly-named component are recognized by the linter.
- Separate type-only imports from value imports (use-render-cursors, fields stories, media-fields stories, dependency-extraction-webpack) - Rename test variables to satisfy testing-library naming convention (markdown.test.ts: body → view) - Add comment explaining Playwright fixture use() is not a React hook - Fix method signatures in gutenberg-test-env type declarations
- Move @wordpress/block-editor import after @wordpress/rich-text (self-import should come after external package imports) - Name anonymous arrow function in withFormatTypes HOC to fix react/display-name
|
Flaky tests detected in 711064e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23909686849
|
Per review feedback, move the __experimental/__unstable aliases from the source files to the barrel re-export files. The internal functions keep their valid use* names, and the prefixed aliases are applied at the re-export boundary.
36915a7 to
711064e
Compare
|
This should be good to go. |
What?
Extracted out of #76654
Fixes pre-existing lint errors that will surface when upgrading ESLint plugins. All changes are backward-compatible with the current ESLint v8 configuration.
Why?
Extracting these fixes from the main ESLint v10 upgrade PR (#76654) to reduce its diff size and make review easier.
How?
Playwright test fixes
toHaveAttribute,toHaveValue) to satisfyplaywright/prefer-web-first-assertionsplaywright/valid-title)Named function exports (fixes
react/display-name)Anonymous arrow function component exports lack a
displayName. 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*/__unstable*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__experimentalUseEntityRecorduseDeprecatedEntityRecordsas__experimentalUseEntityRecordsuseDeprecatedResourcePermissionsas__experimentalUseResourcePermissionsuseDeprecatedRichTextas__unstableUseRichTextRichTextInputEventas__unstableRichTextInputEventType import and naming fixes
typeimports from value imports (use-render-cursors.ts,fields/stories,media-fields/stories,dependency-extraction-webpack types.d.ts)testing-library/render-result-naming-convention(markdown.test.ts:body→view)use()is not a React hook (test.ts)gutenberg-test-envtype declarationsNo behavior change — all public APIs remain identical.
Testing Instructions
npm run lint:js— no new errorsnpm run test:unit -- packages/core-data— all tests passnpm run test:unit -- packages/rich-text— all tests passTesting Instructions for Keyboard
N/A — no UI changes.
Screenshots or screencast
N/A — code cleanup only.