Skip to content

fix: effect-needs-cleanup false positive with renamed React Navigation receiver - #1958

Draft
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1956-50f9
Draft

skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1956-50f9

Conversation

@skoshx

@skoshx skoshx commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1956 - effect-needs-cleanup was incorrectly checking variable names before analyzing initializers, causing false positives when the useNavigation() result was renamed to something other than navigation.

Root Cause

The rule's isKnownReactNavigationReceiver function checked if (receiver.name === "navigation") return true; at the start, before checking if the receiver was initialized from useNavigation() from @react-navigation/. This caused two issues:

  1. Variables named navigation were accepted without verifying they came from React Navigation
  2. Variables from useNavigation() but renamed (e.g., coveredNavigation) were rejected

Solution

Reordered the checks to:

  1. First check if initialized from useNavigation() from @react-navigation/ (accepts regardless of variable name)
  2. Recursively check initializer chains
  3. Fall back to name check only when there's no initializer (preserves support for navigation props, a common React Navigation pattern)

Testing

  • ✅ Added unit tests in effect-needs-cleanup-issue-1956.test.ts covering:
    • Renamed receiver from useNavigation()
    • Standard name from useNavigation()
    • Prop named navigation
  • ✅ Added regression test in effect-needs-cleanup.test.ts
  • ✅ All 1136 oxlint-plugin tests pass
  • ✅ All 39 regression tests pass
  • ✅ Lint passes
  • ✅ Typecheck passes
  • ⏳ Parity check: baseline scan in progress (8423 repos, ETA ~3-4 hours)

Validation

Tested with the exact reproduction case from #1956:

$ node packages/react-doctor/bin/react-doctor.js test.tsx --verbose --no-score
✔ No issues found!

Before fix: reported 1 false positive on line 13 (renamed receiver)
After fix: no issues (correct)

Scope

This is a targeted fix that only affects React Navigation addListener cleanup detection. The change:

  • Fixes false positives when useNavigation() result is renamed
  • Preserves backward compatibility with navigation props (common pattern)
  • Does not change behavior for any other patterns

The fix only reorders existing checks - no new logic added, making it safe and minimal.

Closes #1956

Open in Web Open in Cursor 

…p regardless of receiver name

The rule was incorrectly checking variable names before analyzing the
actual initializer, causing false positives when the useNavigation()
result was renamed to something other than 'navigation'.

The fix:
1. First checks if initialized from useNavigation() from @react-navigation/
   (accepts regardless of variable name)
2. Recursively checks initializer chains
3. Falls back to name check only when there's no initializer
   (preserves support for navigation props)

Fixes #1956

Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1958
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1958
npm i https://pkg.pr.new/react-doctor@1958

commit: 2ae859e

Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 2ae859e.

@github-actions

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

Terminal Control verified the built CLI at 2ae859e in a real PTY:

  • selected a project interactively and observed Scanning... before the three-second Git delay completed
  • waited for the clean result and exercised the compact report
  • opened copy context and the GitHub Actions confirmation, then cancelled safely

Download the edited MP4 and PNG evidence

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

effect-needs-cleanup: false positive when the receiver is a plain identifier not named navigation (0.9.17)

2 participants