Skip to content

Commit 3b2c62b

Browse files
authored
feat: add support for $bindable rune & update deps (#498)
1 parent 85c75b1 commit 3b2c62b

File tree

97 files changed

+4938
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4938
-18
lines changed

.changeset/great-meals-travel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": minor
3+
---
4+
5+
feat: add support for `$bindable` rune

package.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
4848
},
4949
"peerDependencies": {
50-
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.69"
50+
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.94"
5151
},
5252
"peerDependenciesMeta": {
5353
"svelte": {
@@ -58,56 +58,56 @@
5858
"eslint-scope": "^7.2.2",
5959
"eslint-visitor-keys": "^3.4.3",
6060
"espree": "^9.6.1",
61-
"postcss": "^8.4.35",
61+
"postcss": "^8.4.38",
6262
"postcss-scss": "^4.0.9"
6363
},
6464
"devDependencies": {
6565
"@changesets/changelog-github": "^0.5.0",
6666
"@changesets/cli": "^2.27.1",
6767
"@changesets/get-release-plan": "^4.0.0",
68-
"@ota-meshi/eslint-plugin": "^0.15.2",
68+
"@ota-meshi/eslint-plugin": "^0.15.3",
6969
"@types/benchmark": "^2.1.5",
70-
"@types/chai": "^4.3.12",
71-
"@types/eslint": "^8.56.5",
70+
"@types/chai": "^4.3.14",
71+
"@types/eslint": "^8.56.7",
7272
"@types/eslint-scope": "^3.7.7",
73-
"@types/eslint-visitor-keys": "^3.0.0",
73+
"@types/eslint-visitor-keys": "^3.3.0",
7474
"@types/estree": "^1.0.5",
7575
"@types/mocha": "^10.0.6",
76-
"@types/node": "^20.11.22",
76+
"@types/node": "^20.12.5",
7777
"@types/semver": "^7.5.8",
78-
"@typescript-eslint/eslint-plugin": "^7.1.0",
78+
"@typescript-eslint/eslint-plugin": "^7.5.0",
7979
"@typescript-eslint/parser": "~7.5.0",
8080
"@typescript-eslint/types": "~7.5.0",
8181
"benchmark": "^2.1.4",
8282
"chai": "^4.4.1",
8383
"env-cmd": "^10.1.0",
84-
"esbuild": "^0.20.1",
84+
"esbuild": "^0.20.2",
8585
"esbuild-register": "^3.5.0",
8686
"eslint": "^8.57.0",
8787
"eslint-config-prettier": "^9.1.0",
8888
"eslint-plugin-eslint-comments": "^3.2.0",
89-
"eslint-plugin-json-schema-validator": "^5.0.0",
90-
"eslint-plugin-jsonc": "^2.13.0",
89+
"eslint-plugin-json-schema-validator": "^5.1.0",
90+
"eslint-plugin-jsonc": "^2.15.0",
9191
"eslint-plugin-n": "^16.6.2",
9292
"eslint-plugin-node-dependencies": "^0.11.2",
9393
"eslint-plugin-prettier": "^5.1.3",
94-
"eslint-plugin-regexp": "^2.2.0",
94+
"eslint-plugin-regexp": "^2.4.0",
9595
"eslint-plugin-svelte": "^2.35.1",
96-
"eslint-plugin-yml": "^1.12.2",
96+
"eslint-plugin-yml": "^1.14.0",
9797
"estree-walker": "^3.0.3",
9898
"locate-character": "^3.0.0",
99-
"magic-string": "^0.30.7",
100-
"mocha": "^10.3.0",
99+
"magic-string": "^0.30.9",
100+
"mocha": "^10.4.0",
101101
"mocha-chai-jest-snapshot": "^1.1.4",
102102
"nyc": "^15.1.0",
103103
"prettier": "~3.2.5",
104104
"prettier-plugin-pkg": "^0.18.1",
105105
"prettier-plugin-svelte": "^3.2.2",
106106
"rimraf": "^5.0.5",
107107
"semver": "^7.6.0",
108-
"svelte": "^5.0.0-next.69",
109-
"svelte2tsx": "^0.7.3",
110-
"typescript": "~5.4.0",
108+
"svelte": "^5.0.0-next.94",
109+
"svelte2tsx": "^0.7.6",
110+
"typescript": "~5.4.4",
111111
"typescript-eslint-parser-for-extra-files": "^0.6.0"
112112
},
113113
"publishConfig": {

src/parser/globals.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const globalsForRunes = [
66
"$derived",
77
"$effect",
88
"$props",
9+
"$bindable",
910
"$inspect",
1011
] as const;
1112
const globalsForSvelte5 = [...globalsForSvelte4, ...globalsForRunes];

src/parser/typescript/analyze/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ function analyzeDollarDollarVariables(
260260
case "$derived":
261261
case "$effect":
262262
case "$props":
263+
case "$bindable":
263264
case "$inspect":
264265
// Processed by `analyzeRuneVariables`.
265266
break;
@@ -317,6 +318,7 @@ function analyzeRuneVariables(
317318
continue;
318319
}
319320
switch (globalName) {
321+
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2492
320322
case "$state": {
321323
appendDeclareFunctionVirtualScripts(globalName, [
322324
"<T>(initial: T): T",
@@ -328,6 +330,7 @@ function analyzeRuneVariables(
328330
]);
329331
break;
330332
}
333+
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2535
331334
case "$derived": {
332335
appendDeclareFunctionVirtualScripts(globalName, [
333336
"<T>(expression: T): T",
@@ -337,6 +340,7 @@ function analyzeRuneVariables(
337340
]);
338341
break;
339342
}
343+
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2574
340344
case "$effect": {
341345
appendDeclareFunctionVirtualScripts(globalName, [
342346
"(fn: () => void | (() => void)): void",
@@ -348,10 +352,17 @@ function analyzeRuneVariables(
348352
]);
349353
break;
350354
}
355+
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2655
351356
case "$props": {
352357
appendDeclareFunctionVirtualScripts(globalName, ["<T>(): T"]);
353358
break;
354359
}
360+
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2666
361+
case "$bindable": {
362+
appendDeclareFunctionVirtualScripts(globalName, ["<T>(t?: T): T"]);
363+
break;
364+
}
365+
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2686
355366
case "$inspect": {
356367
appendDeclareFunctionVirtualScripts(globalName, [
357368
`<T extends any[]>(...values: T): { with: (fn: (type: 'init' | 'update', ...values: T) => void) => void }`,

tests/fixtures/parser/ast/$$slots-scope-output-svelte5.json

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"defs": [],
6767
"references": []
6868
},
69+
{
70+
"name": "$bindable",
71+
"identifiers": [],
72+
"defs": [],
73+
"references": []
74+
},
6975
{
7076
"name": "$inspect",
7177
"identifiers": [],

tests/fixtures/parser/ast/docs/template-syntax/02-attributes-and-props/10-scope-output-svelte5.json

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"defs": [],
6767
"references": []
6868
},
69+
{
70+
"name": "$bindable",
71+
"identifiers": [],
72+
"defs": [],
73+
"references": []
74+
},
6975
{
7076
"name": "$inspect",
7177
"identifiers": [],

tests/fixtures/parser/ast/docs/template-syntax/02-attributes-and-props/11-scope-output-svelte5.json

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"defs": [],
6767
"references": []
6868
},
69+
{
70+
"name": "$bindable",
71+
"identifiers": [],
72+
"defs": [],
73+
"references": []
74+
},
6975
{
7076
"name": "$inspect",
7177
"identifiers": [],

tests/fixtures/parser/ast/docs/template-syntax/13-slot/02-$$slots/01-scope-output-svelte5.json

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"defs": [],
6767
"references": []
6868
},
69+
{
70+
"name": "$bindable",
71+
"identifiers": [],
72+
"defs": [],
73+
"references": []
74+
},
6975
{
7076
"name": "$inspect",
7177
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/fine-grained-reactivity/example01-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@
113113
"defs": [],
114114
"references": []
115115
},
116+
{
117+
"name": "$bindable",
118+
"identifiers": [],
119+
"defs": [],
120+
"references": []
121+
},
116122
{
117123
"name": "$inspect",
118124
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/functions/01-untrack-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
}
9292
]
9393
},
94+
{
95+
"name": "$bindable",
96+
"identifiers": [],
97+
"defs": [],
98+
"references": []
99+
},
94100
{
95101
"name": "$inspect",
96102
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/old-vs-new/01-counter-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
"defs": [],
116116
"references": []
117117
},
118+
{
119+
"name": "$bindable",
120+
"identifiers": [],
121+
"defs": [],
122+
"references": []
123+
},
118124
{
119125
"name": "$inspect",
120126
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/old-vs-new/02-tracking-dependencies-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
"defs": [],
115115
"references": []
116116
},
117+
{
118+
"name": "$bindable",
119+
"identifiers": [],
120+
"defs": [],
121+
"references": []
122+
},
117123
{
118124
"name": "$inspect",
119125
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/old-vs-new/03-untracking-dependencies-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
"defs": [],
115115
"references": []
116116
},
117+
{
118+
"name": "$bindable",
119+
"identifiers": [],
120+
"defs": [],
121+
"references": []
122+
},
117123
{
118124
"name": "$inspect",
119125
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/old-vs-new/04-simple-component-props-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
}
6868
]
6969
},
70+
{
71+
"name": "$bindable",
72+
"identifiers": [],
73+
"defs": [],
74+
"references": []
75+
},
7076
{
7177
"name": "$inspect",
7278
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/old-vs-new/05-advanced-component-props-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
}
6868
]
6969
},
70+
{
71+
"name": "$bindable",
72+
"identifiers": [],
73+
"defs": [],
74+
"references": []
75+
},
7076
{
7177
"name": "$inspect",
7278
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/old-vs-new/06-autoscroll-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
"defs": [],
115115
"references": []
116116
},
117+
{
118+
"name": "$bindable",
119+
"identifiers": [],
120+
"defs": [],
121+
"references": []
122+
},
117123
{
118124
"name": "$inspect",
119125
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/01-$state-frozen-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
"defs": [],
6868
"references": []
6969
},
70+
{
71+
"name": "$bindable",
72+
"identifiers": [],
73+
"defs": [],
74+
"references": []
75+
},
7076
{
7177
"name": "$inspect",
7278
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/01-$state-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
"defs": [],
6868
"references": []
6969
},
70+
{
71+
"name": "$bindable",
72+
"identifiers": [],
73+
"defs": [],
74+
"references": []
75+
},
7076
{
7177
"name": "$inspect",
7278
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/02-$derived-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
"defs": [],
9292
"references": []
9393
},
94+
{
95+
"name": "$bindable",
96+
"identifiers": [],
97+
"defs": [],
98+
"references": []
99+
},
94100
{
95101
"name": "$inspect",
96102
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/02-2-$derived-by-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
"defs": [],
9292
"references": []
9393
},
94+
{
95+
"name": "$bindable",
96+
"identifiers": [],
97+
"defs": [],
98+
"references": []
99+
},
94100
{
95101
"name": "$inspect",
96102
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/03-$effect-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
"defs": [],
116116
"references": []
117117
},
118+
{
119+
"name": "$bindable",
120+
"identifiers": [],
121+
"defs": [],
122+
"references": []
123+
},
118124
{
119125
"name": "$inspect",
120126
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/04-$effect-pre-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
"defs": [],
6868
"references": []
6969
},
70+
{
71+
"name": "$bindable",
72+
"identifiers": [],
73+
"defs": [],
74+
"references": []
75+
},
7076
{
7177
"name": "$inspect",
7278
"identifiers": [],

tests/fixtures/parser/ast/svelte5/docs/runes/05-$props-scope-output.json

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
}
6868
]
6969
},
70+
{
71+
"name": "$bindable",
72+
"identifiers": [],
73+
"defs": [],
74+
"references": []
75+
},
7076
{
7177
"name": "$inspect",
7278
"identifiers": [],

0 commit comments

Comments
 (0)