diff --git a/lib/rules/no-jquery-methods.js b/lib/rules/no-jquery-methods.js index 45886d5..ca22f8a 100644 --- a/lib/rules/no-jquery-methods.js +++ b/lib/rules/no-jquery-methods.js @@ -62,6 +62,10 @@ module.exports = { MemberExpression(node) { let propertyName = get(node, 'property.name'); + // If the node doesn't have a name, return early. + if (!propertyName) { + return; + } let blackListName = BLACKLIST.includes(propertyName) ? propertyName : false; let isThisExpression = get(node, 'object.type').includes('ThisExpression'); diff --git a/tests/lib/rules/no-jquery-methods.js b/tests/lib/rules/no-jquery-methods.js index fc95342..8d501d4 100644 --- a/tests/lib/rules/no-jquery-methods.js +++ b/tests/lib/rules/no-jquery-methods.js @@ -74,6 +74,24 @@ ruleTester.run('no-jquery-methods', rule, { } });`, options: [] + }, + { + code: ` + export default Ember.Component({ + init() { + const myVar = this[this.myProp]; + } + });`, + options: [BLACKLISTMETHOD] + }, + { + code: ` + export default Ember.Component({ + init() { + const q = this[\`\${myVar}\`]; + } + });`, + options: [BLACKLISTMETHOD] } ], invalid: [