diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js index afef755f5..a4dee6f21 100644 --- a/lib/utils/indent-common.js +++ b/lib/utils/indent-common.js @@ -269,6 +269,8 @@ function isTrivialToken (token) { * @returns {object} AST event handlers. */ module.exports.defineVisitor = function create (context, tokenStore, defaultOptions) { + if (!context.getFilename().endsWith('.vue')) return {} + const options = parseOptions(context.options[0], context.options[1] || {}, defaultOptions) const sourceCode = context.getSourceCode() const offsets = new Map() diff --git a/tests/fixtures/script-indent/if-statement-04.js b/tests/fixtures/script-indent/if-statement-04.js deleted file mode 100644 index 41831505e..000000000 --- a/tests/fixtures/script-indent/if-statement-04.js +++ /dev/null @@ -1,4 +0,0 @@ -/*{}*/ -if (a) - b; -c diff --git a/tests/fixtures/script-indent/if-statement-04.vue b/tests/fixtures/script-indent/if-statement-04.vue new file mode 100644 index 000000000..e6ba11eb4 --- /dev/null +++ b/tests/fixtures/script-indent/if-statement-04.vue @@ -0,0 +1,7 @@ + + + diff --git a/tests/fixtures/script-indent/if-statement-05.js b/tests/fixtures/script-indent/if-statement-05.js deleted file mode 100644 index 4e9af67f4..000000000 --- a/tests/fixtures/script-indent/if-statement-05.js +++ /dev/null @@ -1,6 +0,0 @@ -/*{}*/ -function wrap() { - if (x) - this.doSomething(); - foo -} diff --git a/tests/fixtures/script-indent/opts-baseindent1.js b/tests/fixtures/script-indent/opts-baseindent1.js deleted file mode 100644 index e5456c834..000000000 --- a/tests/fixtures/script-indent/opts-baseindent1.js +++ /dev/null @@ -1,16 +0,0 @@ -/*{"options":[2,{"baseIndent":1}]}*/ -var aaa = { - test: 1 -} -var bbb = { - test: 1 - }, - ccc = { - test: 1 - } -const ddd = { - test: 1 - }, - eee = (a) => { - foo(a) - } diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js index b2f7ebe0b..a0613009a 100644 --- a/tests/lib/rules/html-indent.js +++ b/tests/lib/rules/html-indent.js @@ -108,114 +108,151 @@ tester.run('html-indent', rule, loadPatterns( // Valid [ // TemplateLiteral - unIndent` - - `, + test + \` + " + > + + ` + }, // VAttribute - unIndent` - - `, + { + filename: 'test.vue', + code: unIndent` + + ` + }, // Comments - unIndent` - - `, - unIndent` - - `, - unIndent` -