Skip to content

Commit f2f7d4b

Browse files
committed
Fixed false positives for TSImportType in vue/script-indent rule
1 parent c36cae5 commit f2f7d4b

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lib/utils/indent-ts.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,14 +1199,27 @@ function defineVisitor({
11991199
isOpeningParenToken
12001200
)
12011201
setOffset(leftParenToken, 1, firstToken)
1202-
const argument =
1203-
node.argument ||
1204-
/** @type {any} typescript-eslint v5 */ (node).parameter
1202+
1203+
let source
1204+
const args = []
1205+
if (node.source) {
1206+
source = node.source
1207+
args.push(source)
1208+
if (node.options) {
1209+
args.push(node.options)
1210+
}
1211+
} else {
1212+
// For old typescript-eslint parser
1213+
source =
1214+
node.argument ||
1215+
/** @type {any} typescript-eslint v5 */ (node).parameter
1216+
args.push(source)
1217+
}
12051218
const rightParenToken = tokenStore.getTokenAfter(
1206-
argument,
1219+
source,
12071220
isClosingParenToken
12081221
)
1209-
processNodeList([argument], leftParenToken, rightParenToken, 1)
1222+
processNodeList(args, leftParenToken, rightParenToken, 1)
12101223
if (node.qualifier) {
12111224
const dotToken = tokenStore.getTokenBefore(node.qualifier)
12121225
const propertyToken = tokenStore.getTokenAfter(dotToken)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"types": "lib/index.d.ts",
77
"scripts": {
88
"new": "node tools/new-rule.js",
9-
"start": "npm run test:base -- --watch --growl",
9+
"start": "npm run test:base -- --watch",
1010
"test:base": "vitest run --reporter=dot tests/lib",
1111
"test": "vitest run",
1212
"test:integrations": "vitest run tests/integrations",

0 commit comments

Comments
 (0)