Skip to content

Commit 991d904

Browse files
nlfurnisslynchbomb
authored andcommitted
Guard propertyName in no-jquery-methods
1 parent aa40fad commit 991d904

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/rules/no-jquery-methods.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ module.exports = {
6262

6363
MemberExpression(node) {
6464
let propertyName = get(node, 'property.name');
65+
// If the node doesn't have a name, return early.
66+
if (!propertyName) {
67+
return;
68+
}
6569
let blackListName = BLACKLIST.includes(propertyName) ? propertyName : false;
6670
let isThisExpression = get(node, 'object.type').includes('ThisExpression');
6771

tests/lib/rules/no-jquery-methods.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ ruleTester.run('no-jquery-methods', rule, {
7474
}
7575
});`,
7676
options: []
77+
},
78+
{
79+
code: `
80+
export default Ember.Component({
81+
init() {
82+
const myVar = this[this.myProp];
83+
}
84+
});`,
85+
options: [BLACKLISTMETHOD]
86+
},
87+
{
88+
code: `
89+
export default Ember.Component({
90+
init() {
91+
const q = this[\`\${myVar}\`];
92+
}
93+
});`,
94+
options: [BLACKLISTMETHOD]
7795
}
7896
],
7997
invalid: [

0 commit comments

Comments
 (0)