Skip to content

Commit 17b4b58

Browse files
committed
update
1 parent d4ef0e5 commit 17b4b58

File tree

5 files changed

+73
-14
lines changed

5 files changed

+73
-14
lines changed

Diff for: src/parser/typescript/analyze/index.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -339,25 +339,23 @@ function analyzeRuneVariables(
339339
continue;
340340
}
341341
switch (globalName) {
342-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2646
342+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2299
343343
case "$state": {
344344
appendDeclareFunctionVirtualScripts(globalName, [
345345
"<T>(initial: T): T",
346346
"<T>(): T | undefined",
347347
]);
348348
appendDeclareNamespaceVirtualScripts(globalName, [
349-
"export function frozen<T>(initial: T): Readonly<T>;",
350-
"export function frozen<T>(): Readonly<T> | undefined;",
349+
"export function raw<T>(initial: T): T;",
350+
"export function raw<T>(): T | undefined;",
351351
]);
352352
appendDeclareNamespaceVirtualScripts(globalName, [
353353
"export function snapshot<T>(state: T): T;",
354354
]);
355-
appendDeclareNamespaceVirtualScripts(globalName, [
356-
"export function is(a: any, b: any): boolean;",
357-
]);
355+
358356
break;
359357
}
360-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2751
358+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2453
361359
case "$derived": {
362360
appendDeclareFunctionVirtualScripts(globalName, [
363361
"<T>(expression: T): T",
@@ -367,7 +365,7 @@ function analyzeRuneVariables(
367365
]);
368366
break;
369367
}
370-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2811
368+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2513
371369
case "$effect": {
372370
appendDeclareFunctionVirtualScripts(globalName, [
373371
"(fn: () => void | (() => void)): void",
@@ -379,24 +377,27 @@ function analyzeRuneVariables(
379377
]);
380378
break;
381379
}
382-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2913
380+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2615
383381
case "$props": {
384-
appendDeclareFunctionVirtualScripts(globalName, ["(): any"]);
382+
// Use type parameters to avoid `@typescript-eslint/no-unsafe-assignment` errors.
383+
appendDeclareFunctionVirtualScripts(globalName, ["<T>(): T"]);
385384
break;
386385
}
387-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2924
386+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2626
388387
case "$bindable": {
389-
appendDeclareFunctionVirtualScripts(globalName, ["<T>(t?: T): T"]);
388+
appendDeclareFunctionVirtualScripts(globalName, [
389+
"<T>(fallback?: T): T",
390+
]);
390391
break;
391392
}
392-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2944
393+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2646
393394
case "$inspect": {
394395
appendDeclareFunctionVirtualScripts(globalName, [
395396
`<T extends any[]>(...values: T): { with: (fn: (type: 'init' | 'update', ...values: T) => void) => void }`,
396397
]);
397398
break;
398399
}
399-
// See https://github.com/sveltejs/svelte/blob/ccb3c90cd57ca9d764efab317ed1cb8e5282926e/packages/svelte/types/index.d.ts#L2967
400+
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2669
400401
case "$host": {
401402
appendDeclareFunctionVirtualScripts(globalName, [
402403
`<El extends HTMLElement = HTMLElement>(): El`,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
const { x }: { x: number} = $props();
3+
</script>
4+
5+
<div>{x}</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parse": {
3+
"svelte": ">=5.0.0-0"
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* eslint eslint-comments/require-description: 0, @typescript-eslint/explicit-module-boundary-types: 0 */
2+
import type { Linter } from "eslint";
3+
import { generateParserOptions } from "../../../src/parser/test-utils";
4+
import { rules } from "@typescript-eslint/eslint-plugin";
5+
export function setupLinter(linter: Linter) {
6+
linter.defineRule(
7+
"@typescript-eslint/no-unsafe-argument",
8+
rules["no-unsafe-argument"] as never,
9+
);
10+
linter.defineRule(
11+
"@typescript-eslint/no-unsafe-assignment",
12+
rules["no-unsafe-assignment"] as never,
13+
);
14+
linter.defineRule(
15+
"@typescript-eslint/no-unsafe-call",
16+
rules["no-unsafe-call"] as never,
17+
);
18+
linter.defineRule(
19+
"@typescript-eslint/no-unsafe-member-access",
20+
rules["no-unsafe-member-access"] as never,
21+
);
22+
linter.defineRule(
23+
"@typescript-eslint/no-unsafe-return",
24+
rules["no-unsafe-return"] as never,
25+
);
26+
}
27+
28+
export function getConfig() {
29+
return {
30+
parser: "svelte-eslint-parser",
31+
parserOptions: {
32+
...generateParserOptions(),
33+
svelteFeatures: { runes: true },
34+
},
35+
rules: {
36+
"@typescript-eslint/no-unsafe-argument": "error",
37+
"@typescript-eslint/no-unsafe-assignment": "error",
38+
"@typescript-eslint/no-unsafe-call": "error",
39+
"@typescript-eslint/no-unsafe-member-access": "error",
40+
"@typescript-eslint/no-unsafe-return": "error",
41+
},
42+
env: {
43+
browser: true,
44+
es2021: true,
45+
},
46+
};
47+
}

0 commit comments

Comments
 (0)