Skip to content
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
12 changes: 6 additions & 6 deletions lib/utils/indent-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions tests/lib/rules/html-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,22 @@ tester.run(
text <span /> <!-- comment --></pre>
</template>
`
},
{
filename: 'test.vue',
code: unIndent`
<template>
<textarea>
</template>
`
},
{
filename: 'test.vue',
code: unIndent`
<template>
<pre>
</template>
`
}
],

Expand Down Expand Up @@ -929,6 +945,25 @@ tester.run(
line: 2
}
]
},
{
filename: 'test.vue',
code: unIndent`
<template>
<textarea>
</template>
`,
output: unIndent`
<template>
<textarea>
</template>
`,
errors: [
{
message: 'Expected indentation of 2 spaces but found 4 spaces.',
line: 2
}
]
}
]
)
Expand Down