UNPKG

1.74 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || function (d, b) {
2 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3 function __() { this.constructor = d; }
4 __.prototype = b.prototype;
5 d.prototype = new __();
6};
7var SyntaxKind = require('./utils/SyntaxKind');
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 UseNamedParameterWalker(sourceFile, this.getOptions()));
16 };
17 Rule.FAILURE_STRING = 'Use a named parameter instead: ';
18 return Rule;
19})(Lint.Rules.AbstractRule);
20exports.Rule = Rule;
21var UseNamedParameterWalker = (function (_super) {
22 __extends(UseNamedParameterWalker, _super);
23 function UseNamedParameterWalker() {
24 _super.apply(this, arguments);
25 }
26 UseNamedParameterWalker.prototype.visitElementAccessExpression = function (node) {
27 if (node.argumentExpression != null) {
28 if (node.argumentExpression.kind === SyntaxKind.current().NumericLiteral) {
29 if (node.expression.getText() === 'arguments') {
30 var failureString = Rule.FAILURE_STRING + '\'' + node.getText() + '\'';
31 var failure = this.createFailure(node.getStart(), node.getWidth(), failureString);
32 this.addFailure(failure);
33 }
34 }
35 }
36 _super.prototype.visitElementAccessExpression.call(this, node);
37 };
38 return UseNamedParameterWalker;
39})(ErrorTolerantWalker);
40//# sourceMappingURL=useNamedParameterRule.js.map
\No newline at end of file