rxjs-tslint-rules
Version:
TSLint rules for RxJS
44 lines (43 loc) • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rule = void 0;
var tslib_1 = require("tslib");
var Lint = tslib_1.__importStar(require("tslint"));
var peer = tslib_1.__importStar(require("../support/peer"));
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new Walker(sourceFile, this.getOptions()));
};
Rule.metadata = {
deprecationMessage: peer.v5 ? peer.v6OnlyMessage : undefined,
description: "Disallows the importation of internals.",
options: null,
optionsDescription: "Not configurable.",
requiresTypeInfo: false,
ruleName: "rxjs-no-internal",
type: "functionality",
typescriptOnly: false,
};
Rule.FAILURE_STRING = "RxJS imports from internal are forbidden";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var Walker = (function (_super) {
tslib_1.__extends(Walker, _super);
function Walker() {
return _super !== null && _super.apply(this, arguments) || this;
}
Walker.prototype.visitImportDeclaration = function (node) {
var moduleSpecifier = node.moduleSpecifier.getText();
var match = moduleSpecifier.match(/^['"]rxjs\/internal\/\w+/);
if (match) {
this.addFailureAtNode(node.moduleSpecifier, Rule.FAILURE_STRING);
}
_super.prototype.visitImportDeclaration.call(this, node);
};
return Walker;
}(Lint.RuleWalker));