lint: promote 138 plain : any annotations to : unknown (cumulative −135)#45
Closed
adm01-debug wants to merge 1 commit into
Closed
lint: promote 138 plain : any annotations to : unknown (cumulative −135)#45adm01-debug wants to merge 1 commit into
: any annotations to : unknown (cumulative −135)#45adm01-debug wants to merge 1 commit into
Conversation
Reduces ESLint problem count by ~120 (1939 → 1816). Brings the
no-explicit-any total from 257 → 122 (−135 since R3.3 + this PR).
## scripts/codemod-any-plain.mjs (new)
Token-aware codemod that promotes plain ': any' annotations in:
- Function parameters: '(x: any)' → '(x: unknown)'
- Return types: '): any' → '): unknown'
- Variable decls: 'const x: any' → 'const x: unknown'
- Class/interface fields: 'x: any;' → 'x: unknown;'
- Generic defaults: '<T = any>' → '<T = unknown>'
Skips (handled by other tools or too risky):
- 'Record<string, any>' / '[key: string]: any' (codemod-any-to-unknown)
- 'as any' casts (same)
- 'any[]' arrays (same)
- Inside generic args ('<K, any>') — caller-side narrowing risky
The pre-pass strips comments + string literals to a same-length
buffer of spaces so regex matches don't fire inside docs.
Skipped via context analysis (look-back for unmatched '<', preceding
'as ', following '['):
- Inside generic args
- 'as any' casts
- 'any[]' annotations
## Validation
no-explicit-any 257 → 122 violations (−135 cumulative)
eslint 1939 → 1816 problems
tsc --noEmit exit 0 (no type errors introduced)
tests no regressions (42 baseline failures)
138 edits across 62 files, all type-safe per TypeScript.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Apr 28, 2026
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.
Summary
Round 4.1 — promotes 138 plain
: anyannotations to: unknown. No type errors introduced. Builds on PR #38's safe-pattern codemod.no-explicit-anytsc --noEmitnpm run testfailingWhat's transformed
(x: any)(x: unknown)): any): unknownconst x: anyconst x: unknownx: any;x: unknown;<T = any><T = unknown>What's intentionally skipped
Record<string, any>/[key: string]: any— handled by PR lint: promote 105 safeanypatterns tounknown(no-explicit-any −97) #38'scodemod-any-to-unknown.mjsas any— sameany[]arrays — same<K, any>) — caller-side narrowing too risky for mechanical sweep(...args: any[]) => any— may break call-site overloadsCodemod design
Token-aware via a comment+string pre-strip pass (replaces those regions with whitespace, length-preserving) so regex matches don't trigger inside docs. Then context-aware look-back to skip:
<)as anycastsany[]arrays138 edits across 62 files, all type-safe per TypeScript.
https://claude.ai/code/session_01KWeDG
Generated by Claude Code