Conversation
- Skip member calls like Service.use(...) where Service is a local identifier - Preserve detection of React.use(...) and destructured use(...) - Add comprehensive regression tests for local member APIs - Fixes #1797 Co-authored-by: Skosh <skoshx@users.noreply.github.com>
commit: |
Contributor
Interactive terminal E2ETerminal Control verified the built CLI at
|
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.
Root Cause
rules-of-hookswas incorrectly treating all PascalCase member calls with.use()as React hooks, without verifying if the receiver was actually from React.Example false positive:
The issue was in
isHookCallat line 225-240: after checkingisPackageImportedNonReactHookMemberCalleefor imports, the code would return{ hookName: propertyName }for any PascalCase identifier without verifying it resolves to React.Fix
Added a targeted check that verifies
.use()member call receivers actually resolve to React:This reuses the existing
resolveReactImportNamehelper (used for bareuse()calls) to trace the receiver's origin.Scope
Narrowly scoped to
.use()member calls only:Service.use(...)where Service is local → no longer reported (false positive fixed)React.use(...)→ still correctly reported in async functionsuse(...)from React import → still correctly reporteduseState(),useEffect(), other hooks → unchanged behaviorTesting
Service.use)Api.use)Database.use)X.use([]))Parity Status
🔄 In progress: Running
rde run path:/agent/repos/react-doctorto scan the corpus with the fix (1,444+ repos processed so far). Will follow up withrde parity npm:0.9.13 path:/agent/repos/react-doctorcomparison once complete.Given the narrow scope (only
.use()member calls with local receivers), low risk of cross-repo regressions.Checklist
rde parityclean (scan in progress)Closes #1797