Will It Vibe logoWill It Vibe?
SVELTE-004Low severity-4 points

Side effect in a reactive statement

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

A `$:` reactive statement re-runs whenever any value it reads changes, so performing a fetch, timer, console write, or storage write inside one fires the effect at unpredictable times and often more than intended. Keep `$:` for derived values and move side effects into event handlers or onMount. Heuristic: matches a fixed set of side-effect calls.

Why it matters

A `$:` reactive statement re-runs every time any value it references changes, and Svelte decides those dependencies for you. Putting a side effect such as a fetch, a timer, a console write, or a storage write inside one means it fires at times you did not plan and often several times, which causes duplicate network calls and hard-to-trace bugs. This is a heuristic: it matches a fixed set of side-effecting calls.

How to fix it

Keep `$:` for deriving values only, for example $: fullName = first + last. Move side effects into the place that owns them: a user action goes in an event handler, one-time setup goes in onMount, and cleanup goes in the function onMount returns or in onDestroy. If you need a side effect when a specific value changes, gate it explicitly and be deliberate about the dependency.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks