Skip to content

Commit 99e0996

Browse files
committed
fix: handled if fn is undefined
1 parent 37d1de7 commit 99e0996

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/rules/no-store-async.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default createRule("no-store-async", {
2121
Program() {
2222
for (const { node } of extractStoreReferences(context)) {
2323
const [, fn] = node.arguments
24-
if (fn.type !== "ArrowFunctionExpression" || !fn.async) continue
24+
if (!fn || fn.type !== "ArrowFunctionExpression" || !fn.async) {
25+
continue
26+
}
2527

2628
const start = fn.loc?.start ?? { line: 1, column: 0 }
2729
context.report({

tests/fixtures/rules/no-store-async/valid/test01-input.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import { writable, readable, derived } from "svelte/store"
33
const w1 = writable(false, () => {
44
/** do nothing */
55
})
6+
const w2 = writable(false)
67
const r1 = readable(false, () => {
78
/** do nothing */
89
})
10+
const r2 = readable(false)
911
const d1 = derived(a1, ($a1) => {
1012
/** do nothing */
1113
})
14+
const d2 = derived(a1)

0 commit comments

Comments
 (0)