rxjs-tslint-rules
Version:
TSLint rules for RxJS
44 lines (43 loc) • 1.78 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.v5NotSupportedMessage : undefined,
description: "Disallows the importation from index modules.",
options: null,
optionsDescription: "Not configurable.",
requiresTypeInfo: false,
ruleName: "rxjs-no-index",
type: "functionality",
typescriptOnly: false,
};
Rule.FAILURE_STRING = "RxJS imports from index modules 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(\/\w+)?\/index/);
if (match) {
this.addFailureAtNode(node.moduleSpecifier, "RxJS imports from index are forbidden - see https://github.com/ReactiveX/rxjs/issues/4230");
}
_super.prototype.visitImportDeclaration.call(this, node);
};
return Walker;
}(Lint.RuleWalker));