# 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

# πŸ” Implementation