fix: no-loading-flag-reset-outside-finally false positive with trailing reset - #1595
Draft
skoshx wants to merge 1 commit into
Draft
fix: no-loading-flag-reset-outside-finally false positive with trailing reset#1595skoshx wants to merge 1 commit into
skoshx wants to merge 1 commit into
Conversation
…ng reset The rule incorrectly flagged trailing resets after non-rethrowing catch blocks when the catch contained user code calls like toast.show(). Root cause: The rule conservatively assumed all potentially-throwing calls in catch handlers would prevent trailing resets from running. This created false positives for user code that doesn't actually throw. Fix: When checking if a catch handler can bypass a trailing reset, use lenient mode that only flags: - Explicit throw/return statements - Calls to local functions proven to always throw - Built-in calls that might throw (JSON.parse, Math.round, etc.) User code calls on non-built-in objects are now assumed safe, resolving the conflict with React Compiler which cannot handle try/finally. Fixes #1593 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 #1593 - False positive where
no-loading-flag-reset-outside-finallyincorrectly flagged trailing resets after non-rethrowing catch blocks when the catch contained user code calls liketoast.show().Root Cause
The rule conservatively assumed all potentially-throwing calls in catch handlers would prevent trailing resets from running. This created false positives for user code that doesn't actually throw.
The pattern from the issue:
This is safe: if the catch doesn't rethrow, the trailing reset will run on both success and rejection paths.
The Fix
Modified
subtreeHasAbruptSynchronousOperationto use lenient mode when checking catch handlers with trailing resets. Lenient mode only flags:const rethrow = () => { throw ... }; rethrow();JSON.parse(),Math.round(1n),console[method]()User code calls on non-built-in objects (like
toast.show()) are now assumed safe.Why This Matters
This resolves the conflict with React Compiler, which cannot handle
try/finallyand requires thecatch-without-rethrow + trailing-resetpattern. From the issue:Testing
Parity
Running
rde parityto validate no cross-repo regressions. Results will be added as a comment.Closes #1593