diff --git a/.changeset/rich-bags-turn.md b/.changeset/rich-bags-turn.md new file mode 100644 index 000000000..f27e55a2a --- /dev/null +++ b/.changeset/rich-bags-turn.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-vue": patch +--- + +Fixed false positives for `TSImportType` in `vue/script-indent` rule diff --git a/lib/utils/indent-ts.js b/lib/utils/indent-ts.js index 8db40869f..034bde947 100644 --- a/lib/utils/indent-ts.js +++ b/lib/utils/indent-ts.js @@ -1199,14 +1199,25 @@ function defineVisitor({ isOpeningParenToken ) setOffset(leftParenToken, 1, firstToken) - const argument = - node.argument || - /** @type {any} typescript-eslint v5 */ (node).parameter + + const args = [] + if (node.source) { + args.push(node.source) + } else { + // For old typescript-eslint parser + args.push( + node.argument || + /** @type {any} typescript-eslint v5 */ (node).parameter + ) + } + if (node.options) { + args.push(node.options) + } const rightParenToken = tokenStore.getTokenAfter( - argument, + args[args.length - 1], isClosingParenToken ) - processNodeList([argument], leftParenToken, rightParenToken, 1) + processNodeList(args, leftParenToken, rightParenToken, 1) if (node.qualifier) { const dotToken = tokenStore.getTokenBefore(node.qualifier) const propertyToken = tokenStore.getTokenAfter(dotToken) diff --git a/package.json b/package.json index 7e0dce997..ed938933f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "types": "lib/index.d.ts", "scripts": { "new": "node tools/new-rule.js", - "start": "npm run test:base -- --watch --growl", + "start": "npm run test:base -- --watch", "test:base": "vitest run --reporter=dot tests/lib", "test": "vitest run", "test:integrations": "vitest run tests/integrations",