Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Give competing effects a coordinated resource owner
Coordinate effects that compete for one resource; shared dependencies alone are not a defect.
Bad example
| 1 | useEffect(() => { widget.setOptions(primary); }, [widget, primary]); |
| 2 | useEffect(() => { widget.setOptions(secondary); }, [widget, secondary]); |
Explanation (EN)
Two independent owners mutating the same external state can overwrite each other.
Objašnjenje (HR)
Good example
| 1 | useEffect(() => { |
| 2 | widget.setOptions({ ...primary, ...secondary }); |
| 3 | }, [widget, primary, secondary]); |
Explanation (EN)
If the intended contract combines these options with secondary precedence, one effect expresses that ownership.
Objašnjenje (HR)
Notes (EN)
Identify the external resource owned by each effect; shared dependencies are normal, but overlapping mutations can need one coordinated owner.
Exceptions / Tradeoffs (EN)
Do not omit dependencies or invent guards to prevent legitimate synchronization. Unrelated effects can safely have identical dependencies.