diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000..44e54133
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1 @@
+tests/fixtures
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 00000000..877131f6
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "plugins": ["prettier-plugin-pkg", "prettier-plugin-svelte"]
+}
diff --git a/docs/AST.md b/docs/AST.md
index b8eec7b4..c0f90492 100644
--- a/docs/AST.md
+++ b/docs/AST.md
@@ -15,7 +15,7 @@ See [ESTree] for the AST node of the script generated by `espree`.
[variabledeclarator]: https://github.com/estree/estree/blob/master/es5.md#variabledeclarator
[pattern]: https://github.com/estree/estree/blob/master/es5.md#patterns
-See details: [../src/ast/*](../src/ast/)
+See details: [../src/ast/\*](../src/ast/)
## Common
diff --git a/docs/internal-mechanism.md b/docs/internal-mechanism.md
index 9cc25972..80fead11 100644
--- a/docs/internal-mechanism.md
+++ b/docs/internal-mechanism.md
@@ -38,23 +38,26 @@ For example, if you enter `*.svelte` template to listen for input events:
```svelte
-
+
+
```
Parse the following virtual script code as a script:
```ts
-
- function inputHandler () {
- // process
- }
-;function $_render1(){
-
-(inputHandler) as ((e:'input' extends keyof HTMLElementEventMap ? HTMLElementEventMap['input'] : CustomEvent) => void );
+function inputHandler() {
+ // process
+}
+function $_render1() {
+ inputHandler as (
+ e: "input" extends keyof HTMLElementEventMap
+ ? HTMLElementEventMap["input"]
+ : CustomEvent,
+ ) => void;
}
```
@@ -78,25 +81,24 @@ For example, when using `{#each}` and `{@const}`:
```svelte
+
{#each array as e}
- {@const ee = e * 2}
- {ee}
+ {@const ee = e * 2}
+ {ee}
{/each}
```
Parse the following virtual script code as a script:
```ts
-
- const array = [1, 2, 3]
-;function $_render1(){
-
-Array.from(array).forEach((e) => {
+const array = [1, 2, 3];
+function $_render1() {
+ Array.from(array).forEach((e) => {
const ee = e * 2;
- (ee);
-});
+ ee;
+ });
}
```
@@ -121,8 +123,9 @@ TypeScript's type inference is pretty good, so parsing Svelte as-is gives some w
e.g.
+
```ts
-export let foo: { bar: number } | null = null
+export let foo: { bar: number } | null = null;
$: console.log(foo && foo.bar);
// ^ never type
@@ -139,13 +142,13 @@ For example:
```svelte
{foo && foo.bar}
@@ -154,26 +157,24 @@ $: ({ bar: n } = foo || { bar: 42 });
Parse the following virtual script code as a script:
```ts
-
-export let foo: { bar: number } | null = null
+export let foo: { bar: number } | null = null;
-$: function $_reactiveStatementScopeFunction1(){
- console.log(foo && foo.bar);
+$: function $_reactiveStatementScopeFunction1() {
+ console.log(foo && foo.bar);
}
-$: let r =$_reactiveVariableScopeFunction2();
-function $_reactiveVariableScopeFunction2(){
- let $_tmpVar3;
- return ($_tmpVar3 = foo && foo.bar);
+$: let r = $_reactiveVariableScopeFunction2();
+function $_reactiveVariableScopeFunction2() {
+ let $_tmpVar3;
+ return ($_tmpVar3 = foo && foo.bar);
}
-$: let { bar: n } =$_reactiveVariableScopeFunction4();
-function $_reactiveVariableScopeFunction4(){
- let $_tmpVar5;
- return ($_tmpVar5 = foo || { bar: 42 });
+$: let { bar: n } = $_reactiveVariableScopeFunction4();
+function $_reactiveVariableScopeFunction4() {
+ let $_tmpVar5;
+ return ($_tmpVar5 = foo || { bar: 42 });
}
-;function $_render6(){
-
-(foo && foo.bar);
+function $_render6() {
+ foo && foo.bar;
}
```
diff --git a/package.json b/package.json
index bc680ca8..f75d2663 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
{
"name": "svelte-eslint-parser",
"version": "1.1.2",
+ "type": "module",
"description": "Svelte parser for ESLint",
"repository": "git+https://github.com/sveltejs/svelte-eslint-parser.git",
"homepage": "https://github.com/sveltejs/svelte-eslint-parser#readme",
@@ -14,7 +15,6 @@
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
- "type": "module",
"main": "lib/index.js",
"files": [
"lib"
@@ -40,10 +40,10 @@
"prerelease": "pnpm run clean && pnpm run build",
"preversion": "pnpm run lint && pnpm run test",
"release": "changeset publish",
+ "run-update-fixtures": "pnpm run ts ./tools/update-fixtures.ts",
"test": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
"ts": "node --import tsx/esm",
"update-fixtures": "git add package.json && pnpm i -D svelte@4 && git checkout package.json && pnpm run run-update-fixtures && pnpm i && pnpm run run-update-fixtures",
- "run-update-fixtures": "pnpm run ts ./tools/update-fixtures.ts",
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
},
"peerDependencies": {
@@ -102,7 +102,7 @@
"magic-string": "^0.30.17",
"mocha": "^11.1.0",
"prettier": "~3.5.3",
- "prettier-plugin-pkg": "^0.18.1",
+ "prettier-plugin-pkg": "^0.19.0",
"prettier-plugin-svelte": "^3.3.3",
"rimraf": "^6.0.1",
"semver": "^7.7.1",