UNPKG

1.64 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 ErrorTolerantWalker = require('./utils/ErrorTolerantWalker');
8var AstUtils = require('./utils/AstUtils');
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 NoEvalScriptWalker(sourceFile, this.getOptions()));
16 };
17 Rule.FAILURE_STRING = 'forbidden execScript: ';
18 return Rule;
19})(Lint.Rules.AbstractRule);
20exports.Rule = Rule;
21var NoEvalScriptWalker = (function (_super) {
22 __extends(NoEvalScriptWalker, _super);
23 function NoEvalScriptWalker() {
24 _super.apply(this, arguments);
25 }
26 NoEvalScriptWalker.prototype.visitCallExpression = function (node) {
27 this.validateExpression(node);
28 _super.prototype.visitCallExpression.call(this, node);
29 };
30 NoEvalScriptWalker.prototype.validateExpression = function (node) {
31 var expression = node.expression;
32 var functionName = AstUtils.getFunctionName(node);
33 if (functionName === 'execScript') {
34 var msg = Rule.FAILURE_STRING + expression.getFullText().trim();
35 this.addFailure(this.createFailure(expression.getStart(), expression.getWidth(), msg));
36 }
37 };
38 return NoEvalScriptWalker;
39})(ErrorTolerantWalker);
40//# sourceMappingURL=noExecScriptRule.js.map
\No newline at end of file