You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -340,6 +340,7 @@ These rules relate to better ways of doing things to help you avoid problems:
340
340
|[svelte/block-lang](https://sveltejs.github.io/eslint-plugin-svelte/rules/block-lang/)| disallows the use of languages other than those specified in the configuration for the lang attribute of `<script>` and `<style>` blocks. ||
341
341
|[svelte/button-has-type](https://sveltejs.github.io/eslint-plugin-svelte/rules/button-has-type/)| disallow usage of button without an explicit type attribute ||
342
342
|[svelte/no-at-debug-tags](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/)| disallow the use of `{@debug}`|:star:|
343
+
|[svelte/no-ignored-unsubscribe](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-ignored-unsubscribe/)| disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores. ||
343
344
|[svelte/no-immutable-reactive-statements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-immutable-reactive-statements/)| disallow reactive statements that don't reference reactive values. ||
344
345
|[svelte/no-reactive-functions](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-functions/)| it's not necessary to define functions in reactive statements |:bulb:|
345
346
|[svelte/no-reactive-literals](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-literals/)| don't assign literal values in reactive statements |:bulb:|
Copy file name to clipboardExpand all lines: docs/rules.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ These rules relate to better ways of doing things to help you avoid problems:
53
53
|[svelte/block-lang](./rules/block-lang.md)| disallows the use of languages other than those specified in the configuration for the lang attribute of `<script>` and `<style>` blocks. ||
54
54
|[svelte/button-has-type](./rules/button-has-type.md)| disallow usage of button without an explicit type attribute ||
55
55
|[svelte/no-at-debug-tags](./rules/no-at-debug-tags.md)| disallow the use of `{@debug}`|:star:|
56
+
|[svelte/no-ignored-unsubscribe](./rules/no-ignored-unsubscribe.md)| disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores. ||
56
57
|[svelte/no-immutable-reactive-statements](./rules/no-immutable-reactive-statements.md)| disallow reactive statements that don't reference reactive values. ||
57
58
|[svelte/no-reactive-functions](./rules/no-reactive-functions.md)| it's not necessary to define functions in reactive statements |:bulb:|
58
59
|[svelte/no-reactive-literals](./rules/no-reactive-literals.md)| don't assign literal values in reactive statements |:bulb:|
description: 'disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores.'
6
+
---
7
+
8
+
# svelte/no-ignored-unsubscribe
9
+
10
+
> disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores.
11
+
12
+
-:exclamation: <badgetext="This rule has not been released yet."vertical="middle"type="error"> **_This rule has not been released yet._** </badge>
13
+
14
+
## :book: Rule Details
15
+
16
+
This rule fails if an "unsubscriber" returned by call to `subscribe()` is neither assigned to a variable or property or passed to a function.
17
+
18
+
One should always unsubscribe from a store when it is no longer needed. Otherwise, the subscription will remain active and constitute a **memory leak**.
19
+
This rule helps to find such cases by ensuring that the unsubscriber (the return value from the store's `subscribe` method) is not ignored.
0 commit comments