Skip to content

fix(linter): avoid no-restricted-globals shadowing false positive#20813

Closed
raashish1601 wants to merge 1 commit intooxc-project:mainfrom
raashish1601:contributor-11/oxc-20807
Closed

fix(linter): avoid no-restricted-globals shadowing false positive#20813
raashish1601 wants to merge 1 commit intooxc-project:mainfrom
raashish1601:contributor-11/oxc-20807

Conversation

@raashish1601
Copy link
Copy Markdown

Fixes #20807.

Summary

  • use the existing IsGlobalReference helper so
    o-restricted-globals checks the current reference instead of any unresolved identifier with the same name
  • keep reporting only the unresolved global location access when a later local binding shadows that name in the same file
  • add pass/fail coverage for the mixed global-plus-shadowed-local case from the issue report

Testing

  • cargo test -p oxc_linter --lib no_restricted_globals
  • cargo fmt --all --check

@raashish1601 raashish1601 requested a review from camc314 as a code owner March 27, 2026 20:07
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Mar 27, 2026
@raashish1601
Copy link
Copy Markdown
Author

Closing this as a duplicate now that the same fix path is already covered by #20811.

@ulrichstark
Copy link
Copy Markdown
Contributor

Closing this as a duplicate now that the same fix path is already covered by #20811.

Hey @raashish1601, thanks for your contribution and interest to help! I noticed that #20814 of you is also open. Would you be willing to close that PR as well?

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

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: no-restricted-globals: false positive when file has both global and local variable with the same name

2 participants