UNPKG

1.42 kBJavaScriptView Raw
1/// <reference path="references.ts" />
2var __extends = (this && this.__extends) || function (d, b) {
3 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4 function __() { this.constructor = d; }
5 __.prototype = b.prototype;
6 d.prototype = new __();
7};
8var ErrorTolerantWalker = require('./utils/ErrorTolerantWalker');
9var Rule = (function (_super) {
10 __extends(Rule, _super);
11 function Rule() {
12 _super.apply(this, arguments);
13 }
14 Rule.prototype.apply = function (sourceFile) {
15 return this.applyWithWalker(new NoForInRuleWalker(sourceFile, this.getOptions()));
16 };
17 Rule.FAILURE_STRING = 'Do not use for in statements, use Object.keys instead: ';
18 return Rule;
19})(Lint.Rules.AbstractRule);
20exports.Rule = Rule;
21var NoForInRuleWalker = (function (_super) {
22 __extends(NoForInRuleWalker, _super);
23 function NoForInRuleWalker() {
24 _super.apply(this, arguments);
25 }
26 NoForInRuleWalker.prototype.visitForInStatement = function (node) {
27 var initializer = node.initializer.getText();
28 var expression = node.expression.getText();
29 var msg = Rule.FAILURE_STRING + 'for (' + initializer + ' in ' + expression + ')';
30 this.addFailure(this.createFailure(node.getStart(), node.getWidth(), msg));
31 };
32 return NoForInRuleWalker;
33})(ErrorTolerantWalker);
34//# sourceMappingURL=noForInRule.js.map
\No newline at end of file