fix(lint/noShadow): ignore parameters in function type signatures#9508
fix(lint/noShadow): ignore parameters in function type signatures#9508sudabg wants to merge 2 commits intobiomejs:mainfrom
Conversation
Parameters in function type signatures like (options: unknown) => void are type-only and don't create runtime bindings. They should not be flagged for shadowing outer variables. Adds is_inside_function_type() check using TsFunctionType ancestor detection, similar to existing is_inside_type_parameter() and is_inside_type_member() checks. Fixes biomejs#9482
🦋 Changeset detectedLatest commit: 9baba0d The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR updates the Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
| /// function fn(options: unknown, cb: (options: unknown) => void) {} | ||
| /// // ^^^^^^^^ type-only parameter |
There was a problem hiding this comment.
nit: the pointer is misaligned
Merging this PR will not alter performance
Comparing Footnotes
|
dyc3
left a comment
There was a problem hiding this comment.
Actually, looking at the snapshot diff, I'm not convinced this is a complete fix
|
That's a bot, I'll close the PR |
Summary
Fixes #9482
The
noShadowrule incorrectly flags parameter names in function type signatures as shadowing outer variables. For example:Function type parameters are type-only and don't create runtime bindings — they should not trigger shadowing warnings.
Changes
is_inside_function_type()helper that checks if a binding is inside aTsFunctionTypeancestorevaluate_shadowing()to also skip bindings inside function typesThis follows the same pattern as the existing
is_inside_type_parameter()andis_inside_type_member()checks.Test plan
nusery/noShadowshould not flag parameter names of function types #9482 should no longer produce a diagnosticnursery/noShadow: implementignoreTypeValueShadowoption from source rule #7812) should continue to work