Skip to content

Commit 33c70db

Browse files
committed
chore: config prettier correctly
1 parent a3e88a6 commit 33c70db

File tree

5 files changed

+49
-45
lines changed

5 files changed

+49
-45
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/fixtures

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["prettier-plugin-pkg", "prettier-plugin-svelte"]
3+
}

docs/AST.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See [ESTree] for the AST node of the script generated by `espree`.
1515
[variabledeclarator]: https://github.com/estree/estree/blob/master/es5.md#variabledeclarator
1616
[pattern]: https://github.com/estree/estree/blob/master/es5.md#patterns
1717

18-
See details: [../src/ast/*](../src/ast/)
18+
See details: [../src/ast/\*](../src/ast/)
1919

2020
## Common
2121

docs/internal-mechanism.md

+42-42
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,26 @@ For example, if you enter `*.svelte` template to listen for input events:
3838

3939
```svelte
4040
<script lang="ts">
41-
function inputHandler () {
42-
// process
43-
}
41+
function inputHandler() {
42+
// process
43+
}
4444
</script>
45-
<input on:input={inputHandler}>
45+
46+
<input on:input={inputHandler} />
4647
```
4748

4849
Parse the following virtual script code as a script:
4950

5051
```ts
51-
52-
function inputHandler () {
53-
// process
54-
}
55-
;function $_render1(){
56-
57-
(inputHandler) as ((e:'input' extends keyof HTMLElementEventMap ? HTMLElementEventMap['input'] : CustomEvent<any>) => void );
52+
function inputHandler() {
53+
// process
54+
}
55+
function $_render1() {
56+
inputHandler as (
57+
e: "input" extends keyof HTMLElementEventMap
58+
? HTMLElementEventMap["input"]
59+
: CustomEvent<any>,
60+
) => void;
5861
}
5962
```
6063

@@ -78,25 +81,24 @@ For example, when using `{#each}` and `{@const}`:
7881

7982
```svelte
8083
<script lang="ts">
81-
const array = [1, 2, 3]
84+
const array = [1, 2, 3];
8285
</script>
86+
8387
{#each array as e}
84-
{@const ee = e * 2}
85-
{ee}
88+
{@const ee = e * 2}
89+
{ee}
8690
{/each}
8791
```
8892

8993
Parse the following virtual script code as a script:
9094

9195
```ts
92-
93-
const array = [1, 2, 3]
94-
;function $_render1(){
95-
96-
Array.from(array).forEach((e) => {
96+
const array = [1, 2, 3];
97+
function $_render1() {
98+
Array.from(array).forEach((e) => {
9799
const ee = e * 2;
98-
(ee);
99-
});
100+
ee;
101+
});
100102
}
101103
```
102104

@@ -122,10 +124,10 @@ TypeScript's type inference is pretty good, so parsing Svelte as-is gives some w
122124
e.g.
123125

124126
```ts
125-
export let foo: { bar: number } | null = null
127+
export let foo: { bar: number } | null = null;
126128

127129
$: console.log(foo && foo.bar);
128-
// ^ never type
130+
// ^ never type
129131
```
130132

131133
(You can see it on [TypeScript Online Playground](https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAG2PAZhCAuOBvOAjAQyiwDsBXAWz2CjgF84AfOchBOAXhbLYFgAoAQBIsAYwgkAzhCQA6BBADmACjQQ4AMg1w1swlACUAbgFwz5i5YsB6a3AB6LYADcacGAE8wwAUA))
@@ -139,13 +141,13 @@ For example:
139141

140142
```svelte
141143
<script lang="ts">
142-
export let foo: { bar: number } | null = null
144+
export let foo: { bar: number } | null = null;
143145
144-
$: console.log(foo && foo.bar);
146+
$: console.log(foo && foo.bar);
145147
146-
$: r = foo && foo.bar;
148+
$: r = foo && foo.bar;
147149
148-
$: ({ bar: n } = foo || { bar: 42 });
150+
$: ({ bar: n } = foo || { bar: 42 });
149151
</script>
150152
151153
{foo && foo.bar}
@@ -154,26 +156,24 @@ $: ({ bar: n } = foo || { bar: 42 });
154156
Parse the following virtual script code as a script:
155157

156158
```ts
157-
158-
export let foo: { bar: number } | null = null
159+
export let foo: { bar: number } | null = null;
159160

160-
$: function $_reactiveStatementScopeFunction1(){
161-
console.log(foo && foo.bar);
161+
$: function $_reactiveStatementScopeFunction1() {
162+
console.log(foo && foo.bar);
162163
}
163164

164-
$: let r =$_reactiveVariableScopeFunction2();
165-
function $_reactiveVariableScopeFunction2(){
166-
let $_tmpVar3;
167-
return ($_tmpVar3 = foo && foo.bar);
165+
$: let r = $_reactiveVariableScopeFunction2();
166+
function $_reactiveVariableScopeFunction2() {
167+
let $_tmpVar3;
168+
return ($_tmpVar3 = foo && foo.bar);
168169
}
169170

170-
$: let { bar: n } =$_reactiveVariableScopeFunction4();
171-
function $_reactiveVariableScopeFunction4(){
172-
let $_tmpVar5;
173-
return ($_tmpVar5 = foo || { bar: 42 });
171+
$: let { bar: n } = $_reactiveVariableScopeFunction4();
172+
function $_reactiveVariableScopeFunction4() {
173+
let $_tmpVar5;
174+
return ($_tmpVar5 = foo || { bar: 42 });
174175
}
175-
;function $_render6(){
176-
177-
(foo && foo.bar);
176+
function $_render6() {
177+
foo && foo.bar;
178178
}
179179
```

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "svelte-eslint-parser",
33
"version": "1.1.2",
4+
"type": "module",
45
"description": "Svelte parser for ESLint",
56
"repository": "git+https://github.com/sveltejs/svelte-eslint-parser.git",
67
"homepage": "https://github.com/sveltejs/svelte-eslint-parser#readme",
@@ -14,7 +15,6 @@
1415
"engines": {
1516
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
1617
},
17-
"type": "module",
1818
"main": "lib/index.js",
1919
"files": [
2020
"lib"
@@ -40,10 +40,10 @@
4040
"prerelease": "pnpm run clean && pnpm run build",
4141
"preversion": "pnpm run lint && pnpm run test",
4242
"release": "changeset publish",
43+
"run-update-fixtures": "pnpm run ts ./tools/update-fixtures.ts",
4344
"test": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
4445
"ts": "node --import tsx/esm",
4546
"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",
46-
"run-update-fixtures": "pnpm run ts ./tools/update-fixtures.ts",
4747
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
4848
},
4949
"peerDependencies": {

0 commit comments

Comments
 (0)