diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js
index 704e8726c..c8719a98a 100644
--- a/lib/utils/indent-common.js
+++ b/lib/utils/indent-common.js
@@ -798,10 +798,12 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti
VElement (node) {
const startTagToken = tokenStore.getFirstToken(node)
- const childTokens = node.children.map(n => tokenStore.getFirstToken(n))
const endTagToken = node.endTag && tokenStore.getFirstToken(node.endTag)
- setOffset(childTokens, 1, startTagToken)
+ if (node.name !== 'pre') {
+ const childTokens = node.children.map(n => tokenStore.getFirstToken(n))
+ setOffset(childTokens, 1, startTagToken)
+ }
setOffset(endTagToken, 0, startTagToken)
},
diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js
index e97aae5f2..b2f7ebe0b 100644
--- a/tests/lib/rules/html-indent.js
+++ b/tests/lib/rules/html-indent.js
@@ -230,6 +230,19 @@ tester.run('html-indent', rule, loadPatterns(
// Ignore all :D
ignores: ['*']
}]
+ },
+
+ // Pre
+ {
+ code: unIndent`
+
+
+ aaa
+ bbb
+ ccc
+
+
+ `
}
],
@@ -480,6 +493,38 @@ tester.run('html-indent', rule, loadPatterns(
{ message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 6 }
]
+ },
+
+ // Pre
+ {
+ code: unIndent`
+
+
+ aaa
+ bbb
+ ccc
+
+
+ `,
+ output: unIndent`
+
+
+ aaa
+ bbb
+ ccc
+
+
+ `,
+ errors: [
+ { message: 'Expected indentation of 2 spaces but found 0 spaces.', line: 2 },
+ { message: 'Expected indentation of 4 spaces but found 0 spaces.', line: 3 },
+ { message: 'Expected indentation of 2 spaces but found 0 spaces.', line: 4 },
+ { message: 'Expected indentation of 2 spaces but found 0 spaces.', line: 8 }
+ ]
}
]
))