disallow-reactive-vars-on-mount
#1205onMount runs in the component lifecycle, while reactive variables operate within the reactivity lifecycle. Referencing reactive variables inside the component lifecycle can easily lead to bugs.
You cannot access reactive variables inside the onMount function.
<script>
import { onMount } from 'svelte';
let count = $state(0);
// ✗ BAD
onMount(() => {
console.log(count);
});
</script>
<!-- ✓ GOOD -->
{#if count > 0}
<p>Count is positive</p>
{/if}
No response