Skip to content

Commit a696f99

Browse files
committed
Issue #472 timeout service fail on jasmine.getGlobal().setTimeout
1 parent ee57435 commit a696f99

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

rules/timeout-service.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
return {
2121

2222
MemberExpression: function(node) {
23-
if (node.property.name !== 'setTimeout') {
23+
if (node.property.name !== 'setTimeout' || !node.object) {
2424
return;
2525
}
2626

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

38+
if (!parentNode.object) {
39+
return;
40+
}
41+
3842
if (parentNode.object.type === 'ThisExpression' && parentNode.property.name === '$window') {
3943
context.report(node, message, {});
4044
}

test/timeout-service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var message = 'You should use the $timeout service instead of the default window
1818

1919
eslintTester.run('timeout-service', rule, {
2020
valid: [
21+
'jasmine.getGlobal().setTimeout',
2122
'$timeout(function() {})',
2223
'$timeout(function() {}, 1000)',
2324
'$timeout(function() {}, 1000, true)',

0 commit comments

Comments
 (0)