Skip to content

Commit e020ee0

Browse files
authored
Merge pull request #24 from chadhietala/graceful-gets
[Bugfix] Cautiously path into AST nodes
2 parents 1ab8377 + e40d84a commit e020ee0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/rules/no-attrs-snapshot.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
const { get } = require('../utils/get');
2+
13
function hasAttrsSnapShot(node) {
2-
let methodName = node.parent.key.name;
4+
let methodName = get(node, 'parent.key.name');
35
let hasParams = node.params.length > 0;
46
return (methodName === 'didReceiveAttrs' || methodName === 'didUpdateAttrs') && hasParams;
57
}

lib/rules/no-unguarded-document.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const { isGuarded } = require('../utils/fast-boot');
2+
const { get } = require('../utils/get');
23

34
const MESSAGE = 'Do not use unguarded document references. Please see the following guide for more infromation: http://github.com/chadhietala/ember-best-practices/files/guides/no-unguarded-document.md';
45

56
function isDocumentReference(node) {
6-
return node.callee.object.name === 'document';
7+
return get(node, 'callee.object.name') === 'document';
78
}
89

910
module.exports = {
@@ -19,4 +20,4 @@ module.exports = {
1920
}
2021
};
2122
}
22-
};
23+
};

0 commit comments

Comments
 (0)