Repository navigation
ESLint Plugin: Ship type declarations for the public API - #82739
Open
USERSATOSHI wants to merge 5 commits into
Open
USERSATOSHI wants to merge 5 commits into
USERSATOSHI wants to merge 5 commits into
Conversation
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
USERSATOSHI
marked this pull request as ready for review
September 11, 2026 06:46
|
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #82494
Adds TypeScript type declarations to
@wordpress/eslint-plugin, so it can be used from a type-checkedeslint.config.tswithout adeclare moduleshim.Why?
The package ships no declarations, so importing it in a typed flat config fails:
With
typescript-eslintstrict rules on, the resultinganyalso triggersno-unsafe-member-accessandno-unsafe-assignmentin the config itself. Consumers currently work around it with an ambient module shim.How?
Adds three declaration files under
packages/eslint-plugin/types/:shared.d.ts: theConfigNameandRuleNameunions,PluginMetaandRules, shared by both entry points.index.d.ts: the main export, withconfigstyped asRecord<ConfigName, Linter.Config[]>.eslintrc.d.ts: the same for the deprecated/eslintrcexport, usingLinter.LegacyConfig.Config and rule names are string literal unions, so only names the plugin actually exports are accepted.
ESLint.Pluginwas not reused directly because it typesconfigsasRecord<string, unknown>, which loses that precision. The plugin object is still assignable toESLint.Plugin.Also:
package.json: adds thetypesfield, atypescondition on both export subpaths, andtypestofiles.@types/eslintdev dependency. ESLint ships its own types since 9.10, and having both risks checking against the older DefinitelyTyped shapes. Only this package declared it.tsconfig.json: adds the declarations tofilesand widensrootDirto.so they are type checked.Testing Instructions
npm installnpm run typecheckpasses.npm run lint:jsandnpm run lint:pkg-jsonpass.To check the consumer side:
npm pack --workspace @wordpress/eslint-pluginInstall the tarball in a scratch project with
eslint@^10,typescript,jitiandtypescript-eslint.Add an
eslint.config.ts:tsc --noEmitreports TS7016 before this change and passes after.wordpress.configs[ 'not-a-config' ]andwordpress.rules[ 'not-a-rule' ]should be type errors.eslint .still works the same. No rule or config code changed.Testing Instructions for Keyboard
N/A, no UI changes.
Screenshots or screencast
N/A, types only.
Use of AI Tools
Claude Code was used to draft the declaration files, the config wiring and this description. I reviewed everything manually and tested on latest version of eslint.