Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for $bindable rune & update deps #498

Merged
merged 3 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/great-meals-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": minor
---

feat: add support for `$bindable` rune
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
},
"peerDependencies": {
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.69"
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.94"
},
"peerDependenciesMeta": {
"svelte": {
Expand All @@ -58,56 +58,56 @@
"eslint-scope": "^7.2.2",
"eslint-visitor-keys": "^3.4.3",
"espree": "^9.6.1",
"postcss": "^8.4.35",
"postcss": "^8.4.38",
"postcss-scss": "^4.0.9"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@changesets/get-release-plan": "^4.0.0",
"@ota-meshi/eslint-plugin": "^0.15.2",
"@ota-meshi/eslint-plugin": "^0.15.3",
"@types/benchmark": "^2.1.5",
"@types/chai": "^4.3.12",
"@types/eslint": "^8.56.5",
"@types/chai": "^4.3.14",
"@types/eslint": "^8.56.7",
"@types/eslint-scope": "^3.7.7",
"@types/eslint-visitor-keys": "^3.0.0",
"@types/eslint-visitor-keys": "^3.3.0",
"@types/estree": "^1.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.22",
"@types/node": "^20.12.5",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "~7.5.0",
"@typescript-eslint/types": "~7.5.0",
"benchmark": "^2.1.4",
"chai": "^4.4.1",
"env-cmd": "^10.1.0",
"esbuild": "^0.20.1",
"esbuild": "^0.20.2",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-json-schema-validator": "^5.0.0",
"eslint-plugin-jsonc": "^2.13.0",
"eslint-plugin-json-schema-validator": "^5.1.0",
"eslint-plugin-jsonc": "^2.15.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-node-dependencies": "^0.11.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-regexp": "^2.2.0",
"eslint-plugin-regexp": "^2.4.0",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-yml": "^1.12.2",
"eslint-plugin-yml": "^1.14.0",
"estree-walker": "^3.0.3",
"locate-character": "^3.0.0",
"magic-string": "^0.30.7",
"mocha": "^10.3.0",
"magic-string": "^0.30.9",
"mocha": "^10.4.0",
"mocha-chai-jest-snapshot": "^1.1.4",
"nyc": "^15.1.0",
"prettier": "~3.2.5",
"prettier-plugin-pkg": "^0.18.1",
"prettier-plugin-svelte": "^3.2.2",
"rimraf": "^5.0.5",
"semver": "^7.6.0",
"svelte": "^5.0.0-next.69",
"svelte2tsx": "^0.7.3",
"typescript": "~5.4.0",
"svelte": "^5.0.0-next.94",
"svelte2tsx": "^0.7.6",
"typescript": "~5.4.4",
"typescript-eslint-parser-for-extra-files": "^0.6.0"
},
"publishConfig": {
Expand Down
1 change: 1 addition & 0 deletions src/parser/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const globalsForRunes = [
"$derived",
"$effect",
"$props",
"$bindable",
"$inspect",
] as const;
const globalsForSvelte5 = [...globalsForSvelte4, ...globalsForRunes];
Expand Down
11 changes: 11 additions & 0 deletions src/parser/typescript/analyze/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function analyzeDollarDollarVariables(
case "$derived":
case "$effect":
case "$props":
case "$bindable":
case "$inspect":
// Processed by `analyzeRuneVariables`.
break;
Expand Down Expand Up @@ -317,6 +318,7 @@ function analyzeRuneVariables(
continue;
}
switch (globalName) {
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2492
case "$state": {
appendDeclareFunctionVirtualScripts(globalName, [
"<T>(initial: T): T",
Expand All @@ -328,6 +330,7 @@ function analyzeRuneVariables(
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2535
case "$derived": {
appendDeclareFunctionVirtualScripts(globalName, [
"<T>(expression: T): T",
Expand All @@ -337,6 +340,7 @@ function analyzeRuneVariables(
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2574
case "$effect": {
appendDeclareFunctionVirtualScripts(globalName, [
"(fn: () => void | (() => void)): void",
Expand All @@ -348,10 +352,17 @@ function analyzeRuneVariables(
]);
break;
}
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2655
case "$props": {
appendDeclareFunctionVirtualScripts(globalName, ["<T>(): T"]);
break;
}
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2666
case "$bindable": {
appendDeclareFunctionVirtualScripts(globalName, ["<T>(t?: T): T"]);
break;
}
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2686
case "$inspect": {
appendDeclareFunctionVirtualScripts(globalName, [
`<T extends any[]>(...values: T): { with: (fn: (type: 'init' | 'update', ...values: T) => void) => void }`,
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/parser/ast/$$slots-scope-output-svelte5.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
}
]
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
}
]
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
}
]
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
"defs": [],
"references": []
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
}
]
},
{
"name": "$bindable",
"identifiers": [],
"defs": [],
"references": []
},
{
"name": "$inspect",
"identifiers": [],
Expand Down