diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js index 826e1b8c9..2f2ec5745 100644 --- a/lib/utils/indent-common.js +++ b/lib/utils/indent-common.js @@ -278,7 +278,7 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti const options = parseOptions(context.options[0], context.options[1] || {}, defaultOptions) const sourceCode = context.getSourceCode() const offsets = new Map() - const preformattedTokens = new Set() + const ignoreTokens = new Set() /** * Set offset to the given tokens. @@ -341,9 +341,9 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti ) } for (const token of tokenStore.getTokensBetween(node.startTag, endToken, option)) { - preformattedTokens.add(token) + ignoreTokens.add(token) } - preformattedTokens.add(endToken) + ignoreTokens.add(endToken) } /** @@ -600,6 +600,7 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti function ignore (node) { for (const token of tokenStore.getTokens(node)) { offsets.delete(token) + ignoreTokens.add(token) } } @@ -861,8 +862,8 @@ module.exports.defineVisitor = function create (context, tokenStore, defaultOpti } } - // It does not validate preformatted tokens. - if (preformattedTokens.has(firstToken)) { + // It does not validate ignore tokens. + if (ignoreTokens.has(firstToken)) { return } diff --git a/tests/fixtures/html-indent/opts-ignores-vattribute-01.vue b/tests/fixtures/html-indent/opts-ignores-vattribute-01.vue new file mode 100644 index 000000000..d503a2044 --- /dev/null +++ b/tests/fixtures/html-indent/opts-ignores-vattribute-01.vue @@ -0,0 +1,19 @@ + + diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js index 2fa78893e..81a773402 100644 --- a/tests/lib/rules/html-indent.js +++ b/tests/lib/rules/html-indent.js @@ -756,6 +756,25 @@ tester.run('html-indent', rule, loadPatterns( { message: 'Expected indentation of 4 spaces but found 0 spaces.', line: 7 }, { message: 'Expected indentation of 2 spaces but found 0 spaces.', line: 8 } ] + }, + { + filename: 'test.vue', + code: unIndent` + + `, + output: unIndent` + + `, + options: ['tab', { 'ignores': ['VAttribute'] }], + errors: [ + { message: 'Expected "\\t" character, but found " " character.', line: 2 } + ] } ] ))