Skip to content

Commit 6531988

Browse files
authored
Fix incompatibility with typescript-eslint v6 in vue/script-indent rule (#2256)
1 parent 56180e3 commit 6531988

File tree

14 files changed

+69
-65
lines changed

14 files changed

+69
-65
lines changed

.circleci/config.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- run:
4545
name: Install eslint@6
4646
command: |
47-
npm install --save-exact eslint@6.8.0
47+
npm install --save-exact eslint@6.8.0 @typescript-eslint/parser@5
4848
- run:
4949
name: Install dependencies
5050
command: npm install
@@ -62,7 +62,7 @@ jobs:
6262
- run:
6363
name: Install eslint@7
6464
command: |
65-
npm install eslint@7
65+
npm install eslint@7 @typescript-eslint/parser@5
6666
- run:
6767
name: Install dependencies
6868
command: npm install
@@ -88,9 +88,23 @@ jobs:
8888
name: Test
8989
command: npm test
9090
node-v14:
91-
<<: *node-base
9291
docker:
9392
- image: node:14
93+
steps:
94+
- run:
95+
name: Versions
96+
command: npm version
97+
- checkout
98+
- run:
99+
name: Install @typescript-eslint/parser@5
100+
command: |
101+
npm install @typescript-eslint/parser@5 --save-exact
102+
- run:
103+
name: Install dependencies
104+
command: npm install
105+
- run:
106+
name: Test
107+
command: npm test
94108
node-v16:
95109
<<: *node-base
96110
docker:

.github/workflows/CI.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ jobs:
1717
uses: actions/checkout@v3
1818
- name: Install Node.js
1919
uses: actions/setup-node@v3
20-
with:
21-
node-version: 16
2220
- name: Install Packages
2321
run: npm install --legacy-peer-deps
2422
- name: Lint
@@ -28,7 +26,7 @@ jobs:
2826
name: Test
2927
strategy:
3028
matrix:
31-
node: [17, 18]
29+
node: [17, 18, 20]
3230
os: [ubuntu-latest]
3331

3432
runs-on: ${{ matrix.os }}
@@ -43,3 +41,20 @@ jobs:
4341
run: npm install --legacy-peer-deps
4442
- name: Test
4543
run: npm test
44+
45+
test-for-ts-eslint-v5:
46+
name: Test
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v3
51+
- name: Install Node.js v${{ matrix.node }}
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: 18
55+
- name: Install Packages
56+
run: npm install --legacy-peer-deps
57+
- name: Install typescript-eslint v5
58+
run: npm install -D @typescript-eslint/parser
59+
- name: Test
60+
run: npm test

docs/.vitepress/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// @ts-expect-error -- Cannot change `module` option
12
import type { DefaultTheme } from 'vitepress'
3+
// @ts-expect-error -- Cannot change `module` option
24
import { defineConfig } from 'vitepress'
35
import { BUNDLED_LANGUAGES } from 'shiki'
46
import path from 'path'

docs/.vitepress/theme/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ if (typeof window !== 'undefined') {
99
}
1010
}
1111
}
12+
// @ts-expect-error -- Cannot change `module` option
1213
import type { Theme } from 'vitepress'
14+
// @ts-expect-error -- Cannot change `module` option
1315
import DefaultTheme from 'vitepress/theme'
1416
// @ts-expect-error -- ignore
1517
import Layout from './Layout.vue'

docs/.vitepress/vite-plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-expect-error -- Cannot change `module` option
12
import type { UserConfig } from 'vitepress'
23
import path from 'path'
34
import { fileURLToPath } from 'url'

lib/utils/indent-ts.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,18 +1168,24 @@ function defineVisitor({
11681168
isOpeningParenToken
11691169
)
11701170
setOffset(leftParenToken, 1, firstToken)
1171+
const argument =
1172+
node.argument ||
1173+
/** @type {any} typescript-eslint v5 */ (node).parameter
11711174
const rightParenToken = tokenStore.getTokenAfter(
1172-
node.parameter,
1175+
argument,
11731176
isClosingParenToken
11741177
)
1175-
processNodeList([node.parameter], leftParenToken, rightParenToken, 1)
1178+
processNodeList([argument], leftParenToken, rightParenToken, 1)
11761179
if (node.qualifier) {
11771180
const dotToken = tokenStore.getTokenBefore(node.qualifier)
11781181
const propertyToken = tokenStore.getTokenAfter(dotToken)
11791182
setOffset([dotToken, propertyToken], 1, firstToken)
11801183
}
1181-
if (node.typeParameters) {
1182-
setOffset(tokenStore.getFirstToken(node.typeParameters), 1, firstToken)
1184+
const typeArguments =
1185+
node.typeArguments ||
1186+
/** @type {any} typescript-eslint v5 */ (node).typeParameters
1187+
if (typeArguments) {
1188+
setOffset(tokenStore.getFirstToken(typeArguments), 1, firstToken)
11831189
}
11841190
},
11851191
TSParameterProperty(node) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"@types/node": "^14.18.54",
7171
"@types/semver": "^7.5.0",
7272
"@types/xml-name-validator": "^4.0.1",
73-
"@typescript-eslint/parser": "^5.45.0",
73+
"@typescript-eslint/parser": "^6.2.0",
74+
"@typescript-eslint/types": "^6.2.0",
7475
"assert": "^2.0.0",
7576
"env-cmd": "^10.1.0",
7677
"esbuild": "^0.18.17",

tests/fixtures/script-indent/ts-class-declaration-04.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ class
55
<
66
T
77
>
8+
extends
9+
Bar
10+
<
11+
T
12+
>
813
implements
914
Baz1
1015
<
@@ -15,11 +20,6 @@ class
1520
<
1621
T
1722
>
18-
extends
19-
Bar
20-
<
21-
T
22-
>
2323
{
2424
prop:string
2525
}

tests/fixtures/script-indent/ts-class-declaration-05.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<script lang="ts">
33
class
44
Foo
5+
extends
6+
Bar
57
implements
68
Baz1
79
,
810
Baz2
9-
extends
10-
Bar
1111
{
1212
prop:string
1313
}

tests/fixtures/script-indent/ts-class-declaration-06.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ class
2323
boolean
2424
=
2525
false
26-
)
26+
) {}
2727
}
2828
</script>

0 commit comments

Comments
 (0)