noDebuggerRule.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. var __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. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var Lint = require("../lint");
  8. var Rule = (function (_super) {
  9. __extends(Rule, _super);
  10. function Rule() {
  11. _super.apply(this, arguments);
  12. }
  13. Rule.prototype.apply = function (sourceFile) {
  14. return this.applyWithWalker(new NoDebuggerWalker(sourceFile, this.getOptions()));
  15. };
  16. Rule.FAILURE_STRING = "use of debugger statements is disallowed";
  17. return Rule;
  18. }(Lint.Rules.AbstractRule));
  19. exports.Rule = Rule;
  20. var NoDebuggerWalker = (function (_super) {
  21. __extends(NoDebuggerWalker, _super);
  22. function NoDebuggerWalker() {
  23. _super.apply(this, arguments);
  24. }
  25. NoDebuggerWalker.prototype.visitDebuggerStatement = function (node) {
  26. var debuggerKeywordNode = node.getChildAt(0);
  27. this.addFailure(this.createFailure(debuggerKeywordNode.getStart(), debuggerKeywordNode.getWidth(), Rule.FAILURE_STRING));
  28. _super.prototype.visitDebuggerStatement.call(this, node);
  29. };
  30. return NoDebuggerWalker;
  31. }(Lint.RuleWalker));