Skip to content

Commit

Permalink
Guard propertyName in no-jquery-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nlfurniss authored and lynchbomb committed Aug 31, 2017
1 parent aa40fad commit 991d904
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/no-jquery-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
18 changes: 18 additions & 0 deletions tests/lib/rules/no-jquery-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 991d904

Please sign in to comment.