Conversation
…ation as valid state sync Recognize when a mutation explicitly fetches fresh data and updates a Zustand store as valid state synchronization, similar to query cache invalidation. Detection is conservative - only treats setState as synchronization when: 1. The setState argument uses dynamic data (identifiers/calls, not literals) 2. An await expression precedes the setState in the same function 3. The store binding is a Zustand store (create/createStore result) This avoids false negatives from unrelated UI state updates while correctly handling the reported pattern of explicit data reconciliation. Closes #1786 Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
commit: |
Contributor
Interactive terminal E2ETerminal Control verified the built CLI at
|
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
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
Fixes #1786
The
query-mutation-missing-invalidationrule now correctly recognizes when a mutation explicitly fetches fresh data and updates a Zustand store as valid state synchronization, eliminating a false positive.Root Cause
The rule was designed to detect when TanStack Query mutations don't invalidate cached query data, which can lead to stale UI. However, it flagged mutations that synchronize state through alternative state management (Zustand) even when they explicitly fetch fresh data and update the relevant store.
The Fix
Extended the cache-update detection to recognize a Zustand reconciliation pattern:
resolveZustandStoreFactoryCallto identify Zustand stores.setState()on Zustand storesawaitexpression precedes the setState (indicating fresh data fetch)This prevents false negatives by still flagging:
setState({ isOpen: false }))Scope
Conservative and narrow: Only suppresses the warning when all conditions are met. The pattern must show clear evidence of explicit data reconciliation.
Example from the issue:
This is now correctly recognized as valid synchronization.
Testing
Notes
Full corpus parity scan was not run due to baseline data unavailability in the cloud environment. The fix is low-risk because: