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'] + } + ]) })