Skip to content

Commit

Permalink
fix: typescript-eslint v6 compatibility (#385)
Browse files Browse the repository at this point in the history
* fix: typescript-eslint v6 compatibility

* Create lazy-cups-fry.md

* fix test

* fix testcase

* fix ci
  • Loading branch information
ota-meshi authored Jul 20, 2023
1 parent df45c22 commit 71db4ec
Show file tree
Hide file tree
Showing 15 changed files with 907 additions and 833 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-cups-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

fix: typescript-eslint v6 compatibility
24 changes: 22 additions & 2 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,27 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install Svelte v3
run: |+
pnpm install -D svelte@3
pnpm install -D svelte@3 @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5
rm -rf node_modules
- name: Install Packages
run: pnpm install
- name: Test
run: pnpm run test
test-for-ts-eslint-v5:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install @typescript-eslint v5
run: |+
pnpm install -D @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5
rm -rf node_modules
- name: Install Packages
run: pnpm install
Expand Down Expand Up @@ -89,7 +109,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install eslint v7
run: |+
pnpm install -D eslint@7 svelte@3
pnpm install -D eslint@7 svelte@3 @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5
rm -rf node_modules
- name: Install Packages
run: pnpm install
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
"@types/mocha": "^10.0.1",
"@types/node": "^18.16.16",
"@types/semver": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "~5.62.0",
"@typescript-eslint/types": "^5.59.9",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "~6.1.0",
"@typescript-eslint/types": "^6.1.0",
"benchmark": "^2.1.4",
"chai": "^4.3.7",
"env-cmd": "^10.1.0",
Expand Down
3 changes: 1 addition & 2 deletions src/parser/parser-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export function isTSESLintParserObject(
return Boolean(
services &&
services.esTreeNodeToTSNodeMap &&
services.tsNodeToESTreeNodeMap &&
services.program,
services.tsNodeToESTreeNodeMap,
);
} catch {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/parser/typescript/analyze/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ function transformForDeclareReactiveVar(
const newBody: TSESTree.ExpressionStatement = {
type: "ExpressionStatement" as TSESTree.ExpressionStatement["type"],
expression: assignment,
directive: undefined,
loc: statement.body.loc,
range: statement.body.range,
parent: reactiveStatement,
Expand Down
38 changes: 19 additions & 19 deletions tests/fixtures/parser/ast/issue325-eslint-plugin-svelte-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -540,25 +540,7 @@
"type": "TSTypeAnnotation",
"typeAnnotation": {
"type": "TSTypeReference",
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
119,
126
],
"loc": {
"start": {
"line": 3,
"column": 58
},
"end": {
"line": 3,
"column": 65
}
}
},
"typeParameters": {
"typeArguments": {
"type": "TSTypeParameterInstantiation",
"params": [
{
Expand Down Expand Up @@ -594,6 +576,24 @@
}
}
},
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
119,
126
],
"loc": {
"start": {
"line": 3,
"column": 58
},
"end": {
"line": 3,
"column": 65
}
}
},
"range": [
119,
134
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9656,25 +9656,7 @@
"type": "TSTypeAnnotation",
"typeAnnotation": {
"type": "TSTypeReference",
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
119,
126
],
"loc": {
"start": {
"line": 3,
"column": 58
},
"end": {
"line": 3,
"column": 65
}
}
},
"typeParameters": {
"typeArguments": {
"type": "TSTypeParameterInstantiation",
"params": [
{
Expand Down Expand Up @@ -9710,6 +9692,24 @@
}
}
},
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
119,
126
],
"loc": {
"start": {
"line": 3,
"column": 58
},
"end": {
"line": 3,
"column": 65
}
}
},
"range": [
119,
134
Expand Down Expand Up @@ -10433,25 +10433,7 @@
"type": "TSTypeAnnotation",
"typeAnnotation": {
"type": "TSTypeReference",
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
119,
126
],
"loc": {
"start": {
"line": 3,
"column": 58
},
"end": {
"line": 3,
"column": 65
}
}
},
"typeParameters": {
"typeArguments": {
"type": "TSTypeParameterInstantiation",
"params": [
{
Expand Down Expand Up @@ -10487,6 +10469,24 @@
}
}
},
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
119,
126
],
"loc": {
"start": {
"line": 3,
"column": 58
},
"end": {
"line": 3,
"column": 65
}
}
},
"range": [
119,
134
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/parser/ast/ts-event03-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
}
},
"optional": false,
"typeParameters": {
"typeArguments": {
"type": "TSTypeParameterInstantiation",
"params": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/parser/ast/ts-event03-scope-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -8832,7 +8832,7 @@
}
},
"optional": false,
"typeParameters": {
"typeArguments": {
"type": "TSTypeParameterInstantiation",
"params": [
{
Expand Down
38 changes: 19 additions & 19 deletions tests/fixtures/parser/ast/ts-promise01-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,7 @@
"type": "TSTypeAnnotation",
"typeAnnotation": {
"type": "TSTypeReference",
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
32,
39
],
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 20
}
}
},
"typeParameters": {
"typeArguments": {
"type": "TSTypeParameterInstantiation",
"params": [
{
Expand Down Expand Up @@ -237,6 +219,24 @@
}
}
},
"typeName": {
"type": "Identifier",
"name": "Promise",
"range": [
32,
39
],
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 20
}
}
},
"range": [
32,
51
Expand Down
Loading

0 comments on commit 71db4ec

Please sign in to comment.