proposal: no-self-updating-effect#346
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
✅ No new issues Reviewed by reactreview for commit 6109c5f. Configure here. |
681d04b to
b28de92
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b28de92. Configure here.
| const setterCall = getDirectSetterCall( | ||
| callbackStatement, | ||
| setterNames | ||
| ); |
There was a problem hiding this comment.
Misses sync nested setters
Medium Severity
The detector currently only inspects top-level statements within an effect callback. This means it won't catch useState setter calls nested inside control flow structures (like if, loop, or try blocks), even if the corresponding state is in the dependency array and would cause an infinite re-render loop.
Reviewed by Cursor Bugbot for commit b28de92. Configure here.
| context.report({ | ||
| node: setterCall, | ||
| message: `${setterCall.callee.name}() inside a React effect depends on \`${stateName}\` and feeds the same state back into the effect — this causes a render loop. Remove the self-dependency or guard the update so it settles.`, | ||
| }); |
There was a problem hiding this comment.
Ignores fixed-point carve-out
Medium Severity
The detector incorrectly flags patterns that don't cause actual render loops, such as guarded updates that reach a fixed point (which the validation prompt says to ignore) or updates where React bails out due to state equality. This leads to false positives.
Reviewed by Cursor Bugbot for commit b28de92. Configure here.
| if (!isNodeOfType(expression.callee, "Identifier")) return null; | ||
| if (!setterNames.has(expression.callee.name)) return null; | ||
| return expression; | ||
| }; |
There was a problem hiding this comment.
Duplicates existing setter walk utility
Low Severity
The proposal introduces getDirectSetterCall to locate setter calls in effect callbacks, but the plugin already exposes walkInsideStatementBlocks for the same “synchronous effect body” question, used by no-effect-chain and effect-needs-cleanup.
Reviewed by Cursor Bugbot for commit b28de92. Configure here.
Auto-discovered draft proposal. No implementation yet — see file body for the proposed detector + prompts + evidence. See millionco/react-doctor-evals#11 for the discovery pipeline.
b28de92 to
6109c5f
Compare


Proposal:
react-doctor/no-self-updating-effectstate-and-effectswarnNEW::no-self-updating-effectSources
Discovered by the react-doctor-evals discovery flywheel mining bug-fix evidence across React OSS repos. The pipeline below produced this proposal:
Backing evidence
facebook/react—packages/react-reconciler/src/ReactFiberConcurrentUpdates.js(FixCommitMeta)Validation prompt
FP-aware guidance for the react-review agent when triaging this rule:
Fix prompt
Actionable fix suggestion surfaced to the user when the rule fires:
If the value is purely derived, delete the state and compute it directly instead.
Positive fixture (SHOULD trigger)
Negative fixture (should NOT trigger)
Proposed AST detector
Would land at
packages/oxlint-plugin-react-doctor/src/plugin/rules/state-and-effects/no-self-updating-effect.ts:Generated by `rde discover` (see [millionco/react-doctor-evals#11](https://github.com/millionco/react-doctor-evals/pull/11) for the pipeline). Implementation, test fixtures, and rule registration are deliberately deferred — this PR exists for maintainer triage of the proposal only. Reject, edit-and-approve, or merge after wiring as you see fit.
Note
Low Risk
Low risk because this PR only adds a markdown proposal document and does not change any shipped rule logic or runtime behavior.
Overview
Adds a new draft proposal doc
proposals/no-self-updating-effect.mdfor areact-doctor/no-self-updating-effectrule that would warn on React effects which call a localuseStatesetter while also depending on the same state (render-loop feedback pattern).The document includes discovery/backing evidence links, validation and fix guidance, example positive/negative fixtures, and a sketch of the intended AST detector; implementation and registration are explicitly deferred.
Reviewed by Cursor Bugbot for commit b28de92. Bugbot is set up for automated code reviews on this repo. Configure here.