Skip to content

Commit 0b8b4ce

Browse files
committed
fix: handle FunctionExpression also
1 parent 99e0996 commit 0b8b4ce

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/rules/no-store-async.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ export default createRule("no-store-async", {
2121
Program() {
2222
for (const { node } of extractStoreReferences(context)) {
2323
const [, fn] = node.arguments
24-
if (!fn || fn.type !== "ArrowFunctionExpression" || !fn.async) {
24+
if (
25+
!fn ||
26+
(fn.type !== "ArrowFunctionExpression" &&
27+
fn.type !== "FunctionExpression") ||
28+
!fn.async
29+
) {
2530
continue
2631
}
2732

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
- message: Do not pass async functions to svelte stores.
2+
line: 3
3+
column: 28
4+
suggestions: null
5+
- message: Do not pass async functions to svelte stores.
6+
line: 6
7+
column: 28
8+
suggestions: null
9+
- message: Do not pass async functions to svelte stores.
10+
line: 9
11+
column: 24
12+
suggestions: null
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { writable, readable, derived } from "svelte/store"
2+
3+
const w2 = writable(false, async function () {
4+
/** do nothing */
5+
})
6+
const r2 = readable(false, async function () {
7+
/** do nothing */
8+
})
9+
const d2 = derived(a1, async function ($a1) {
10+
/** do nothing */
11+
})

0 commit comments

Comments
 (0)