Skip to content

Commit 39d7da7

Browse files
author
Alex Shnayder
committed
issue 434 - handle setTimeout on object which is not window or $window
1 parent 564b060 commit 39d7da7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

rules/timeout-service.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ module.exports = {
2424
return;
2525
}
2626

27-
if (node.object.type === 'Identifier' && (node.object.name === 'window' || node.object.name === '$window')) {
28-
context.report(node, message, {});
27+
if (node.object.type === 'Identifier') {
28+
if ((node.object.name === 'window' || node.object.name === '$window')){
29+
context.report(node, message, {});
30+
}
31+
2932
return;
3033
}
3134

test/timeout-service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ eslintTester.run('timeout-service', rule, {
2020
valid: [
2121
'$timeout(function() {})',
2222
'$timeout(function() {}, 1000)',
23-
'$timeout(function() {}, 1000, true)'
23+
'$timeout(function() {}, 1000, true)',
24+
'nonWindowObject.setTimeout(function() {})'
2425
].concat(commonFalsePositives),
2526
invalid: [
2627
{code: 'window.setTimeout(function() {}, 1000)', errors: [{message: message}]},

0 commit comments

Comments
 (0)