From 467ef9626ed4d3eeacf47ce4b3d550ed7af0d6ad Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Tue, 2 Mar 2021 19:28:05 +0900 Subject: [PATCH] Fix false negatives for member access with `$` in `vue/this-in-template` rule (#1446) --- lib/rules/this-in-template.js | 2 +- tests/lib/rules/this-in-template.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/rules/this-in-template.js b/lib/rules/this-in-template.js index 0efa03035..8ed42345c 100644 --- a/lib/rules/this-in-template.js +++ b/lib/rules/this-in-template.js @@ -83,7 +83,7 @@ module.exports = { !propertyName || scopeStack.nodes.some((el) => el.name === propertyName) || RESERVED_NAMES.has(propertyName) || // this.class | this['class'] - /^[0-9].*$|[^a-zA-Z0-9_]/.test(propertyName) // this['0aaaa'] | this['foo-bar bas'] + /^[0-9].*$|[^a-zA-Z0-9_$]/.test(propertyName) // this['0aaaa'] | this['foo-bar bas'] ) { return } diff --git a/tests/lib/rules/this-in-template.js b/tests/lib/rules/this-in-template.js index 5f36b570e..f2a40ff61 100644 --- a/tests/lib/rules/this-in-template.js +++ b/tests/lib/rules/this-in-template.js @@ -222,4 +222,16 @@ ruleTester.run('this-in-template', rule, { .concat( createInvalidTests('', ['always'], "Expected 'this'.", 'Identifier') ) + .concat([ + { + code: ``, + errors: ["Unexpected usage of 'this'."], + options: ['never'] + }, + { + code: ``, + errors: ["Unexpected usage of 'this'."], + options: ['never'] + } + ]) })