From c997a37dd38102ca579366f28b736a624e75c076 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Fri, 27 Dec 2019 13:37:15 +0900 Subject: [PATCH 1/2] Fixed: "ignores" option of "html-indent" does not work --- lib/utils/indent-common.js | 11 ++++++----- .../opts-ignores-vattribute-01.vue | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 tests/fixtures/html-indent/opts-ignores-vattribute-01.vue diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js index 227e85adc..a022d61b8 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) } /** @@ -587,6 +587,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) } } @@ -848,8 +849,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 @@ + + From faa6ed97908ce745a56ca57eaebc96200e825c0a Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Fri, 27 Dec 2019 13:43:01 +0900 Subject: [PATCH 2/2] Add testcase that mixed indent --- tests/lib/rules/html-indent.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 } + ] } ] ))