abstractRule.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright 2013 Palantir Technologies, Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. var walker_1 = require("../walker");
  20. var AbstractRule = /** @class */ (function () {
  21. function AbstractRule(options) {
  22. this.options = options;
  23. this.ruleName = options.ruleName;
  24. this.ruleArguments = options.ruleArguments;
  25. this.ruleSeverity = options.ruleSeverity;
  26. }
  27. AbstractRule.prototype.getOptions = function () {
  28. return this.options;
  29. };
  30. AbstractRule.prototype.applyWithWalker = function (walker) {
  31. walker.walk(walker.getSourceFile());
  32. return walker.getFailures();
  33. };
  34. AbstractRule.prototype.isEnabled = function () {
  35. return this.ruleSeverity !== "off";
  36. };
  37. AbstractRule.prototype.applyWithFunction = function (sourceFile, walkFn, options, programOrChecker) {
  38. var ctx = new walker_1.WalkContext(sourceFile, this.ruleName, options);
  39. walkFn(ctx, programOrChecker);
  40. return ctx.failures;
  41. };
  42. /**
  43. * @deprecated
  44. * Failures will be filtered based on `tslint:disable` comments by tslint.
  45. * This method now does nothing.
  46. */
  47. AbstractRule.prototype.filterFailures = function (failures) { return failures; };
  48. return AbstractRule;
  49. }());
  50. exports.AbstractRule = AbstractRule;