diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js
index d208d5a08..6897ea4e7 100644
--- a/lib/utils/indent-common.js
+++ b/lib/utils/indent-common.js
@@ -301,7 +301,7 @@ module.exports.defineVisitor = function create(
tokenStore.getTokenAfter(node)
/** @type {SourceCode.CursorWithSkipOptions} */
- const option = {
+ const cursorOptions = {
includeComments: true,
filter: (token) =>
token != null &&
@@ -311,11 +311,11 @@ module.exports.defineVisitor = function create(
token.type === 'HTMLEndTagOpen' ||
token.type === 'HTMLComment')
}
- for (const token of tokenStore.getTokensBetween(
- node.startTag,
- endToken,
- option
- )) {
+ const contentTokens = endToken
+ ? tokenStore.getTokensBetween(node.startTag, endToken, cursorOptions)
+ : tokenStore.getTokensAfter(node.startTag, cursorOptions)
+
+ for (const token of contentTokens) {
ignoreTokens.add(token)
}
ignoreTokens.add(endToken)
diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js
index 316eb9257..8340f9423 100644
--- a/tests/lib/rules/html-indent.js
+++ b/tests/lib/rules/html-indent.js
@@ -403,6 +403,22 @@ tester.run(
text
`
+ },
+ {
+ filename: 'test.vue',
+ code: unIndent`
+
+
+ `
+ },
+ {
+ filename: 'test.vue',
+ code: unIndent`
+
+
+
+ `
}
],
@@ -929,6 +945,25 @@ tester.run(
line: 2
}
]
+ },
+ {
+ filename: 'test.vue',
+ code: unIndent`
+
+
+ `,
+ output: unIndent`
+
+
+ `,
+ errors: [
+ {
+ message: 'Expected indentation of 2 spaces but found 4 spaces.',
+ line: 2
+ }
+ ]
}
]
)