Skip to content

Commit 796551a

Browse files
committed
docs: add docs
1 parent 7dcaa23 commit 796551a

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
269269
| [svelte/no-not-function-handler](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-not-function-handler/) | disallow use of not function in event handler | :star: |
270270
| [svelte/no-object-in-text-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches/) | disallow objects in text mustache interpolation | :star: |
271271
| [svelte/no-shorthand-style-property-overrides](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-shorthand-style-property-overrides/) | disallow shorthand style properties that override related longhand properties | :star: |
272+
| [svelte/no-store-async](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-store-async.md) | disallow using async/await inside svelte stores | :star: |
272273
| [svelte/no-unknown-style-directive-property](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unknown-style-directive-property/) | disallow unknown `style:property` | :star: |
273274
| [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | :star: |
274275

docs/rules.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
2222
| [svelte/no-not-function-handler](./rules/no-not-function-handler.md) | disallow use of not function in event handler | :star: |
2323
| [svelte/no-object-in-text-mustaches](./rules/no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
2424
| [svelte/no-shorthand-style-property-overrides](./rules/no-shorthand-style-property-overrides.md) | disallow shorthand style properties that override related longhand properties | :star: |
25+
| [svelte/no-store-async](./rules/no-store-async.md) | disallow using async/await inside svelte stores | :star: |
2526
| [svelte/no-unknown-style-directive-property](./rules/no-unknown-style-directive-property.md) | disallow unknown `style:property` | :star: |
2627
| [svelte/valid-compile](./rules/valid-compile.md) | disallow warnings when compiling. | :star: |
2728

docs/rules/no-store-async.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
pageClass: "rule-details"
3+
sidebarDepth: 0
4+
title: "svelte/no-store-async"
5+
description: "disallow using async/await inside svelte stores"
6+
since: "v3.1.0"
7+
---
8+
9+
# svelte/no-store-async
10+
11+
> disallow using async/await inside svelte stores
12+
13+
- :gear: This rule is included in `"plugin:svelte/recommended"`.
14+
15+
## :book: Rule Details
16+
17+
This rule reports all uses of async/await inside svelte stores.
18+
Because it causes issues with the auto-unsubscribing features.
19+
20+
<ESLintCodeBlock language="javascript">
21+
22+
<!--eslint-skip-->
23+
24+
```js
25+
/* eslint svelte/no-store-async: "error" */
26+
27+
import { writable, readable, derived } from "svelte/store"
28+
29+
/* ✓ GOOD */
30+
const w1 = writable(false, () => {})
31+
const r1 = readable(false, () => {})
32+
const d1 = derived(a1, ($a1) => {})
33+
34+
/* ✗ BAD */
35+
const w2 = writable(false, async () => {})
36+
const r2 = readable(false, async () => {})
37+
const d2 = derived(a1, async ($a1) => {})
38+
```
39+
40+
</ESLintCodeBlock>
41+
42+
## :wrench: Options
43+
44+
Nothing.
45+
46+
## :books: Further Reading
47+
48+
- [Svelte - Docs > 4. Prefix stores with $ to access their values / Store contract](https://svelte.dev/docs#component-format-script-4-prefix-stores-with-$-to-access-their-values-store-contract)
49+
50+
## :rocket: Version
51+
52+
This rule was introduced in eslint-plugin-svelte v3.1.0
53+
54+
## :mag: Implementation
55+
56+
- [Rule source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/src/rules/no-store-async.ts)
57+
- [Test source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/tests/src/rules/no-store-async.ts)

0 commit comments

Comments
 (0)