Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: async Svelte#725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ota-meshi merged 9 commits intomainfromfeat/async
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions.changeset/huge-islands-crash.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser":minor
---

feat: support asynchronous svelte
4 changes: 2 additions & 2 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@

# svelte-eslint-parser

## [Svelte](https://svelte.dev/) parser for [ESLint](https://eslint.org/).
## [Svelte](https://svelte.dev/) parser for [ESLint](https://eslint.org/)

[Live DEMO](https://sveltejs.github.io/svelte-eslint-parser/playground) •
[Discord](https://svelte.dev/chat)
Expand DownExpand Up@@ -100,7 +100,7 @@ export default [
parser: svelteParser,
parserOptions: {
sourceType: "module",
ecmaVersion:2021,
ecmaVersion:2024,
ecmaFeatures: {
globalReturn: false,
impliedStrict: false,
Expand Down
2 changes: 1 addition & 1 deletionexplorer-v2/src/lib/ESLintPlayground.svelte
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@
languageOptions: {
parser: svelteEslintParser,
parserOptions: {
ecmaVersion:2020,
ecmaVersion:2024,
sourceType: 'module',
parser: { ts: tsParser, typescript: tsParser }
},
Expand Down
2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -105,7 +105,7 @@
"prettier-plugin-svelte": "^3.3.3",
"rimraf": "^6.0.1",
"semver": "^7.7.1",
"svelte": "^5.30.1",
"svelte": "^5.36.2",
"svelte2tsx": "^0.7.35",
"tsx": "^4.19.3",
"typescript": "~5.8.2",
Expand Down
1 change: 1 addition & 0 deletionssrc/parser/compat.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import type * as SvAST from "./svelte-ast-types.js";
import type * as Compiler from "./svelte-ast-types-for-v5.js";

export type Child =
| Compiler.AttachTag
| Compiler.Text
| Compiler.Tag
| Compiler.ElementLike
Expand Down
2 changes: 1 addition & 1 deletionsrc/parser/parser-options.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,7 @@ export type NormalizedParserOptions = {
/** Normalize parserOptions */
exportfunctionnormalizeParserOptions(options:any):NormalizedParserOptions{
constparserOptions={
ecmaVersion:2020,
ecmaVersion:2024,
sourceType:"module",
loc:true,
range:true,
Expand Down
17 changes: 9 additions & 8 deletionssrc/parser/typescript/analyze/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -399,7 +399,7 @@ function analyzeRuneVariables(
continue;
}
switch (globalName) {
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L2679
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3093
case "$state": {
appendDeclareFunctionVirtualScripts(globalName, [
"<T>(initial: T): T",
Expand All@@ -415,7 +415,7 @@ function analyzeRuneVariables(

break;
}
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L2833
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3247
case "$derived": {
appendDeclareFunctionVirtualScripts(globalName, [
"<T>(expression: T): T",
Expand All@@ -425,35 +425,36 @@ function analyzeRuneVariables(
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L2893
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3307
case "$effect": {
appendDeclareFunctionVirtualScripts(globalName, [
"(fn: () => void | (() => void)): void",
]);
appendDeclareNamespaceVirtualScripts(globalName, [
"export function pre(fn: () => void | (() => void)): void;",
"export function pending(): number;",
"export function tracking(): boolean;",
"export function root(fn: () => void | (() => void)): () => void;",
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L2997
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3416
case "$props": {
//Usetypeparameters to avoid`@typescript-eslint/no-unsafe-assignment` errors.
//NOTE: In the Svelte repository's `index.d.ts`, the returntypeis any, but that triggers`@typescript-eslint/no-unsafe-assignment`. To avoid this, use generics here.
appendDeclareFunctionVirtualScripts(globalName, ["<T>(): T"]);
appendDeclareNamespaceVirtualScripts(globalName, [
"export function id(): string;",
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L3038
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3459
case "$bindable": {
appendDeclareFunctionVirtualScripts(globalName, [
"<T>(fallback?: T): T",
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L3081
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3502
case "$inspect": {
appendDeclareFunctionVirtualScripts(globalName, [
`<T extends any[]>(...values: T): { with: (fn: (type: 'init' | 'update', ...values: T) => void) => void }`,
Expand All@@ -463,7 +464,7 @@ function analyzeRuneVariables(
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/3c4a8d425b8192dc11ea2af256d531c51c37ba5d/packages/svelte/types/index.d.ts#L3144
// See https://github.com/sveltejs/svelte/blob/3fa3dd78a1cbaa88a1571977b76bf6f02ed4231d/packages/svelte/types/index.d.ts#L3565
case "$host": {
appendDeclareFunctionVirtualScripts(globalName, [
`<El extends HTMLElement = HTMLElement>(): El`,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -940,7 +940,7 @@
}
},
{
"type": "Keyword",
"type": "Null",
"value": "null",
"range": [
46,
Expand DownExpand Up@@ -976,7 +976,7 @@
}
},
{
"type": "Keyword",
"type": "Null",
"value": "null",
"range": [
53,
Expand DownExpand Up@@ -1516,7 +1516,7 @@
}
},
{
"type": "Keyword",
"type": "Null",
"value": "null",
"range": [
136,
Expand Down
9 changes: 9 additions & 0 deletionstests/fixtures/parser/ast/svelte5/async/_config.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
{
"svelteConfig": {
"compilerOptions": {
"experimental": {
"async":true
}
}
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
<script>
import MyApp from './MyApp.svelte';
</script>

<svelte:boundary>
<MyApp />

{#snippet pending()}
<p>loading...</p>
{/snippet}
</svelte:boundary>
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp