customRuleRule.js 836 B

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google Inc. All Rights Reserved.
  5. *
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://angular.io/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. const Lint = require('tslint');
  11. class Rule extends Lint.Rules.AbstractRule {
  12. apply(sourceFile) {
  13. const shouldPass = this.getOptions().ruleArguments[0];
  14. if (!shouldPass) {
  15. return [ new Lint.RuleFailure(sourceFile, 0, 0, 'custom-rule fail', this.ruleName) ];
  16. } else {
  17. return [];
  18. }
  19. }
  20. }
  21. Rule.metadata = {
  22. ruleName: 'custom-rule',
  23. description: 'Test.',
  24. rationale: 'Do not use this.',
  25. options: [{ type: 'boolean' }],
  26. optionsDescription: '.',
  27. type: 'functionality',
  28. typescriptOnly: false,
  29. };
  30. exports.Rule = Rule;