# svelte/no-ignored-unsubscribe
disallow ignoring the unsubscribe method returned by the
subscribe()
on Svelte stores.
# π Rule Details
This rule fails if an βunsubscriberβ returned by call to subscribe()
is neither assigned to a variable or property or passed to a function.
One should always unsubscribe from a store when it is no longer needed. Otherwise, the subscription will remain active and constitute a memory leak.
This rule helps to find such cases by ensuring that the unsubscriber (the return value from the storeβs subscribe
method) is not ignored.
<script>
/* eslint svelte/no-ignored-unsubscribe: "error" */
import myStore from './my-stores';
/* β GOOD */
const unsubscribe = myStore.subscribe(() => {});
/* β BAD */
myStore.Ignoring returned value of the subscribe method is forbidden. (svelte/no-ignored-unsubscribe)subscribe(() => {});
</script>
# π§ Options
Nothing.
# π Version
This rule was introduced in eslint-plugin-svelte v2.34.0