# svelte/no-immutable-reactive-statements
disallow reactive statements that donβt reference reactive values.
# π Rule Details
This rule reports if all variables referenced in reactive statements are immutable. That reactive statement is immutable and not reactive.
<script>
/* eslint svelte/no-immutable-reactive-statements: "error" */
import myStore from './my-stores';
import myVar from './my-variables';
let mutableVar = 'hello';
export let prop;
/* β GOOD */
$: computed1 = mutableVar + ' ' + mutableVar;
$: computed2 = fn1(mutableVar);
$: console.log(mutableVar);
$: console.log(computed1);
$: console.log($myStore);
$: console.log(prop);
const immutableVar = 'hello';
/* β BAD */
$: computed3 = This statement is not reactive because all variables referenced in the reactive statement are immutable. (svelte/no-immutable-reactive-statements)fn1(immutableVar);
$: computed4 = This statement is not reactive because all variables referenced in the reactive statement are immutable. (svelte/no-immutable-reactive-statements)fn2();
$: console.log(immutableVar);
$: console.log(myVar);
/* ignore */
$: console.log(unknown);
function fn1(v) {
return v + ' ' + v;
}
function fn2() {
return mutableVar + ' ' + mutableVar;
}
</script>
<input bind:value={mutableVar} />
# π§ Options
Nothing.
# π Version
This rule was introduced in eslint-plugin-svelte v2.27.0