Skip to content

Commit 71db4ec

Browse files
authored
fix: typescript-eslint v6 compatibility (#385)
* fix: typescript-eslint v6 compatibility * Create lazy-cups-fry.md * fix test * fix testcase * fix ci
1 parent df45c22 commit 71db4ec

15 files changed

+907
-833
lines changed

.changeset/lazy-cups-fry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": patch
3+
---
4+
5+
fix: typescript-eslint v6 compatibility

.github/workflows/NodeCI.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,27 @@ jobs:
4949
node-version: ${{ matrix.node-version }}
5050
- name: Install Svelte v3
5151
run: |+
52-
pnpm install -D svelte@3
52+
pnpm install -D svelte@3 @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5
53+
rm -rf node_modules
54+
- name: Install Packages
55+
run: pnpm install
56+
- name: Test
57+
run: pnpm run test
58+
test-for-ts-eslint-v5:
59+
runs-on: ubuntu-latest
60+
strategy:
61+
matrix:
62+
node-version: [18.x]
63+
steps:
64+
- uses: actions/checkout@v3
65+
- uses: pnpm/action-setup@v2
66+
- name: Use Node.js ${{ matrix.node-version }}
67+
uses: actions/setup-node@v3
68+
with:
69+
node-version: ${{ matrix.node-version }}
70+
- name: Install @typescript-eslint v5
71+
run: |+
72+
pnpm install -D @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5
5373
rm -rf node_modules
5474
- name: Install Packages
5575
run: pnpm install
@@ -89,7 +109,7 @@ jobs:
89109
node-version: ${{ matrix.node-version }}
90110
- name: Install eslint v7
91111
run: |+
92-
pnpm install -D eslint@7 svelte@3
112+
pnpm install -D eslint@7 svelte@3 @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5
93113
rm -rf node_modules
94114
- name: Install Packages
95115
run: pnpm install

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
"@types/mocha": "^10.0.1",
7474
"@types/node": "^18.16.16",
7575
"@types/semver": "^7.5.0",
76-
"@typescript-eslint/eslint-plugin": "^5.59.9",
77-
"@typescript-eslint/parser": "~5.62.0",
78-
"@typescript-eslint/types": "^5.59.9",
76+
"@typescript-eslint/eslint-plugin": "^6.1.0",
77+
"@typescript-eslint/parser": "~6.1.0",
78+
"@typescript-eslint/types": "^6.1.0",
7979
"benchmark": "^2.1.4",
8080
"chai": "^4.3.7",
8181
"env-cmd": "^10.1.0",

src/parser/parser-object.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ export function isTSESLintParserObject(
6464
return Boolean(
6565
services &&
6666
services.esTreeNodeToTSNodeMap &&
67-
services.tsNodeToESTreeNodeMap &&
68-
services.program,
67+
services.tsNodeToESTreeNodeMap,
6968
);
7069
} catch {
7170
return false;

src/parser/typescript/analyze/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ function transformForDeclareReactiveVar(
505505
const newBody: TSESTree.ExpressionStatement = {
506506
type: "ExpressionStatement" as TSESTree.ExpressionStatement["type"],
507507
expression: assignment,
508+
directive: undefined,
508509
loc: statement.body.loc,
509510
range: statement.body.range,
510511
parent: reactiveStatement,

tests/fixtures/parser/ast/issue325-eslint-plugin-svelte-output.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -540,25 +540,7 @@
540540
"type": "TSTypeAnnotation",
541541
"typeAnnotation": {
542542
"type": "TSTypeReference",
543-
"typeName": {
544-
"type": "Identifier",
545-
"name": "Promise",
546-
"range": [
547-
119,
548-
126
549-
],
550-
"loc": {
551-
"start": {
552-
"line": 3,
553-
"column": 58
554-
},
555-
"end": {
556-
"line": 3,
557-
"column": 65
558-
}
559-
}
560-
},
561-
"typeParameters": {
543+
"typeArguments": {
562544
"type": "TSTypeParameterInstantiation",
563545
"params": [
564546
{
@@ -594,6 +576,24 @@
594576
}
595577
}
596578
},
579+
"typeName": {
580+
"type": "Identifier",
581+
"name": "Promise",
582+
"range": [
583+
119,
584+
126
585+
],
586+
"loc": {
587+
"start": {
588+
"line": 3,
589+
"column": 58
590+
},
591+
"end": {
592+
"line": 3,
593+
"column": 65
594+
}
595+
}
596+
},
597597
"range": [
598598
119,
599599
134

tests/fixtures/parser/ast/issue325-eslint-plugin-svelte-scope-output.json

+38-38
Original file line numberDiff line numberDiff line change
@@ -9656,25 +9656,7 @@
96569656
"type": "TSTypeAnnotation",
96579657
"typeAnnotation": {
96589658
"type": "TSTypeReference",
9659-
"typeName": {
9660-
"type": "Identifier",
9661-
"name": "Promise",
9662-
"range": [
9663-
119,
9664-
126
9665-
],
9666-
"loc": {
9667-
"start": {
9668-
"line": 3,
9669-
"column": 58
9670-
},
9671-
"end": {
9672-
"line": 3,
9673-
"column": 65
9674-
}
9675-
}
9676-
},
9677-
"typeParameters": {
9659+
"typeArguments": {
96789660
"type": "TSTypeParameterInstantiation",
96799661
"params": [
96809662
{
@@ -9710,6 +9692,24 @@
97109692
}
97119693
}
97129694
},
9695+
"typeName": {
9696+
"type": "Identifier",
9697+
"name": "Promise",
9698+
"range": [
9699+
119,
9700+
126
9701+
],
9702+
"loc": {
9703+
"start": {
9704+
"line": 3,
9705+
"column": 58
9706+
},
9707+
"end": {
9708+
"line": 3,
9709+
"column": 65
9710+
}
9711+
}
9712+
},
97139713
"range": [
97149714
119,
97159715
134
@@ -10433,25 +10433,7 @@
1043310433
"type": "TSTypeAnnotation",
1043410434
"typeAnnotation": {
1043510435
"type": "TSTypeReference",
10436-
"typeName": {
10437-
"type": "Identifier",
10438-
"name": "Promise",
10439-
"range": [
10440-
119,
10441-
126
10442-
],
10443-
"loc": {
10444-
"start": {
10445-
"line": 3,
10446-
"column": 58
10447-
},
10448-
"end": {
10449-
"line": 3,
10450-
"column": 65
10451-
}
10452-
}
10453-
},
10454-
"typeParameters": {
10436+
"typeArguments": {
1045510437
"type": "TSTypeParameterInstantiation",
1045610438
"params": [
1045710439
{
@@ -10487,6 +10469,24 @@
1048710469
}
1048810470
}
1048910471
},
10472+
"typeName": {
10473+
"type": "Identifier",
10474+
"name": "Promise",
10475+
"range": [
10476+
119,
10477+
126
10478+
],
10479+
"loc": {
10480+
"start": {
10481+
"line": 3,
10482+
"column": 58
10483+
},
10484+
"end": {
10485+
"line": 3,
10486+
"column": 65
10487+
}
10488+
}
10489+
},
1049010490
"range": [
1049110491
119,
1049210492
134

tests/fixtures/parser/ast/ts-event03-output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
}
238238
},
239239
"optional": false,
240-
"typeParameters": {
240+
"typeArguments": {
241241
"type": "TSTypeParameterInstantiation",
242242
"params": [
243243
{

tests/fixtures/parser/ast/ts-event03-scope-output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8832,7 +8832,7 @@
88328832
}
88338833
},
88348834
"optional": false,
8835-
"typeParameters": {
8835+
"typeArguments": {
88368836
"type": "TSTypeParameterInstantiation",
88378837
"params": [
88388838
{

tests/fixtures/parser/ast/ts-promise01-output.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,7 @@
111111
"type": "TSTypeAnnotation",
112112
"typeAnnotation": {
113113
"type": "TSTypeReference",
114-
"typeName": {
115-
"type": "Identifier",
116-
"name": "Promise",
117-
"range": [
118-
32,
119-
39
120-
],
121-
"loc": {
122-
"start": {
123-
"line": 2,
124-
"column": 13
125-
},
126-
"end": {
127-
"line": 2,
128-
"column": 20
129-
}
130-
}
131-
},
132-
"typeParameters": {
114+
"typeArguments": {
133115
"type": "TSTypeParameterInstantiation",
134116
"params": [
135117
{
@@ -237,6 +219,24 @@
237219
}
238220
}
239221
},
222+
"typeName": {
223+
"type": "Identifier",
224+
"name": "Promise",
225+
"range": [
226+
32,
227+
39
228+
],
229+
"loc": {
230+
"start": {
231+
"line": 2,
232+
"column": 13
233+
},
234+
"end": {
235+
"line": 2,
236+
"column": 20
237+
}
238+
}
239+
},
240240
"range": [
241241
32,
242242
51

0 commit comments

Comments
 (0)