Remove unused catch block variables across the codebase#76969
Remove unused catch block variables across the codebase#76969manzoorwanijk merged 4 commits intotrunkfrom
Conversation
Use optional catch binding (ES2019) to drop unused error variables from catch blocks. This is a mechanical cleanup with no behavior change — every removed variable was already ignored. Preparing for ESLint v10, which defaults `no-unused-vars` option `caughtErrors` to `'all'`.
|
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. |
|
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. |
1 similar comment
|
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. |
Should we configure that here, to avoid new issues between now and the upgrade landing? I don't think it hurts to be explicit in the configuration anyways. |
Good idea. Thanks |
|
Size Change: -1 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
Set `caughtErrors: 'all'` in `no-unused-vars` and `@typescript-eslint/no-unused-vars` rules to prevent regressions. This matches the ESLint v10 default behavior.
…nfig" This reverts commit f9b8b69.
|
I realized that making the rule change (f9b8b69) to the plugin will be a breaking change for eslint-plugin, so I reverted that and added the change to the repo eslint config. |
f9331b7 to
32fc062
Compare
Makes sense. Let's save the breaking change upgrade for ESLint v10 😅 |
aduth
left a comment
There was a problem hiding this comment.
Nice bit of code clean-up 👍 Also makes me sad to see how much inconsistency we have with naming these variables 😅
|
Flaky tests detected in 32fc062. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23865271590
|
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
What?
Extracted from #76654 (comment)
Removes unused error variables from
catchblocks across 71 files, using ES2019 optional catch binding (catch { ... }instead ofcatch (error) { ... }).Why?
ESLint v10 changes the
no-unused-varsrule default forcaughtErrorsfrom"none"to"all", which flags unused catch block variables as errors. Extracting this mechanical cleanup into a separate PR reduces the size of the main ESLint v10 upgrade PR (#76654) and makes it easier to review.How?
Purely mechanical transformation: every
catch (error),catch (e),catch (err)where the variable is unused is converted tocatch. No behavior change.Testing Instructions
npm run lint:js— should pass (no new errors introduced).npm run test:unit— all tests should pass (no runtime behavior change).Testing Instructions for Keyboard
N/A — no UI changes.
Screenshots or screencast
N/A — code cleanup only.