Skip to content

Fix false positives for trailing comma with import in vue/script-indent rule #1525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/utils/indent-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,11 @@ module.exports.defineVisitor = function create(
}
if (namedSpecifiers.length) {
const leftBrace = tokenStore.getTokenBefore(namedSpecifiers[0])
const rightBrace = tokenStore.getTokenAfter(
namedSpecifiers[namedSpecifiers.length - 1]
const rightBrace = /** @type {Token} */ (
tokenStore.getTokenAfter(
namedSpecifiers[namedSpecifiers.length - 1],
isClosingBraceToken
)
)
processNodeList(namedSpecifiers, leftBrace, rightBrace, 1)
for (const token of tokenStore.getTokensBetween(
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/script-indent/import-declaration-11.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--{ "options": [4, { "baseIndent": 1, "switchCase": 1 } ] }-->
<script>
import {
computed, defineComponent, PropType, ref, watch,
} from '@vue/composition-api';
</script>
<!-- https://github.com/vuejs/eslint-plugin-vue/issues/1524 -->