Skip to content

Use specific JSDoc types to fix ESLint warnings - #2778

Open
mukeshpanchal27 wants to merge 2 commits into
trunkfrom
fix/jsdoc-type-warnings
Open

mukeshpanchal27 wants to merge 2 commits into
trunkfrom
fix/jsdoc-type-warnings

Conversation

@mukeshpanchal27

Copy link
Copy Markdown
Member

Summary

Fixes #2777

This PR removes all 19 ESLint warnings that the JS Lint job reports on trunk. It replaces any, * and Function with specific JSDoc types, and adds the missing @throws type.

Relevant technical choices

  • bin/plugin/cli.js: catchException is now a generic function with a docblock. Each command handler keeps its own parameter types. unknown[] alone does not work here, because TypeScript checks function parameters strictly.
  • webpack.config.js: A new WebpackEnv typedef declares the plugin, zip and force properties. buildPlugin already read zip and force, but no type declared them. buildPlugin now stores the plugin slug in a plugin variable after its check, so the type stays string inside the webpack hook callbacks.
  • plugins/view-transitions/js/view-transitions.js: A new ViewTransitionEntry typedef describes each entry as an element and its view transition name. It replaces "an array of anything".
  • plugins/optimization-detective/detect.js: The logger now uses unknown instead of any and *. recursiveFreeze() takes an Object and casts it only to read a property.
  • bin/plugin/commands/versions.js: @throws Error is now @throws {Error}.

Only JSDoc and type annotations change in the plugin files, so plugin behavior stays the same. The webpack.config.js change affects only the build.

Testing

  • npx eslint . reports no problems. Before this PR, it reported 19 warnings.
  • npm run tsc passes.
  • npm run build and npm run build:plugin:view-transitions succeed.
  • node bin/plugin/cli.js versions --plugin=auto-sizes still reports the version.

Use of AI Tools

I used Claude Code to find the warnings, write the fix, and draft this description. I reviewed the changes and the test results.

🤖 Generated with Claude Code

Replace `any`, `*` and `Function` with specific types, and add the missing
`@throws` type. This removes all 19 warnings that the JS Lint job reports.

The specific types surfaced gaps that `any` was hiding. A `WebpackEnv` typedef
now declares the `plugin`, `zip` and `force` properties, and a
`ViewTransitionEntry` typedef describes each view transition entry.

Fixes #2777

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mukeshpanchal27 mukeshpanchal27 added [Type] Enhancement A suggestion for improvement of an existing feature Infrastructure Issues for the overall performance plugin infrastructure no milestone PRs that do not have a defined milestone for release skip changelog PRs that should not be mentioned in changelogs labels Dec 2, 2026
@github-actions github-actions Bot added [Plugin] Optimization Detective [slug: optimization-detective] [Plugin] View Transitions [slug: view-transitions] labels Dec 2, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@westonruter

Copy link
Copy Markdown
Member

I'll take a look in a couple weeks, at the earliest.

@mukeshpanchal27 mukeshpanchal27 self-assigned this Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Infrastructure Issues for the overall performance plugin infrastructure no milestone PRs that do not have a defined milestone for release [Plugin] Optimization Detective [slug: optimization-detective] [Plugin] View Transitions [slug: view-transitions] skip changelog PRs that should not be mentioned in changelogs [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JSDoc type warnings reported by ESLint

2 participants