Skip to content

Commit

Permalink
Issue #472 timeout service fail on jasmine.getGlobal().setTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed May 27, 2017
1 parent ee57435 commit a696f99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rules/timeout-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
return {

MemberExpression: function(node) {
if (node.property.name !== 'setTimeout') {
if (node.property.name !== 'setTimeout' || !node.object) {
return;
}

Expand All @@ -35,6 +35,10 @@ module.exports = {
// Detect expression this.$window.setTimeout which is what we would see in ES6 code when using classes
var parentNode = node.object;

if (!parentNode.object) {
return;
}

if (parentNode.object.type === 'ThisExpression' && parentNode.property.name === '$window') {
context.report(node, message, {});
}
Expand Down
1 change: 1 addition & 0 deletions test/timeout-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var message = 'You should use the $timeout service instead of the default window

eslintTester.run('timeout-service', rule, {
valid: [
'jasmine.getGlobal().setTimeout',
'$timeout(function() {})',
'$timeout(function() {}, 1000)',
'$timeout(function() {}, 1000, true)',
Expand Down

0 comments on commit a696f99

Please sign in to comment.