|
| 1 | +"use strict"; |
| 2 | +var __extends = (this && this.__extends) || (function () { |
| 3 | + var extendStatics = function (d, b) { |
| 4 | + extendStatics = Object.setPrototypeOf || |
| 5 | + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 6 | + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
| 7 | + return extendStatics(d, b); |
| 8 | + }; |
| 9 | + return function (d, b) { |
| 10 | + extendStatics(d, b); |
| 11 | + function __() { this.constructor = d; } |
| 12 | + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 13 | + }; |
| 14 | +})(); |
| 15 | +exports.__esModule = true; |
| 16 | +var Lint = require("tslint"); |
| 17 | +var Rule = /** @class */ (function (_super) { |
| 18 | + __extends(Rule, _super); |
| 19 | + function Rule() { |
| 20 | + return _super !== null && _super.apply(this, arguments) || this; |
| 21 | + } |
| 22 | + Rule.prototype.apply = function (sourceFile) { |
| 23 | + return this.applyWithWalker(new NoImportsWithRegexWalker(sourceFile, this.getOptions())); |
| 24 | + }; |
| 25 | + return Rule; |
| 26 | +}(Lint.Rules.AbstractRule)); |
| 27 | +exports.Rule = Rule; |
| 28 | +var NoImportsWithRegexWalker = /** @class */ (function (_super) { |
| 29 | + __extends(NoImportsWithRegexWalker, _super); |
| 30 | + function NoImportsWithRegexWalker() { |
| 31 | + return _super !== null && _super.apply(this, arguments) || this; |
| 32 | + } |
| 33 | + NoImportsWithRegexWalker.prototype.visitImportDeclaration = function (node) { |
| 34 | + var options = this.getOptions(); |
| 35 | + for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { |
| 36 | + var regStr = options_1[_i]; |
| 37 | + var importFrom = node.moduleSpecifier.getText(); |
| 38 | + var reg = new RegExp(regStr); |
| 39 | + if (importFrom.match(reg)) { |
| 40 | + this.addFailure(this.createFailure(node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), "importing from " + regStr + " is prohibited.")); |
| 41 | + } |
| 42 | + } |
| 43 | + _super.prototype.visitImportDeclaration.call(this, node); |
| 44 | + }; |
| 45 | + return NoImportsWithRegexWalker; |
| 46 | +}(Lint.RuleWalker)); |
0 commit comments