rxjs-tslint-rules
Version:
TSLint rules for RxJS
41 lines (40 loc) • 1.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rule = void 0;
var tslib_1 = require("tslib");
var tsquery_1 = require("@phenomnomnominal/tsquery");
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) {
var _this = this;
var failures = [];
var importDeclarations = tsquery_1.tsquery(sourceFile, String.raw(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["ImportDeclaration:has(StringLiteral[value=/^rxjs//])"], ["ImportDeclaration:has(StringLiteral[value=/^rxjs\\u002f/])"]))));
importDeclarations.forEach(function (node) {
var importDeclaration = node;
var moduleSpecifier = importDeclaration.moduleSpecifier;
if (!/^['"]rxjs\/(ajax|fetch|operators|testing|webSocket)['"]$/.test(moduleSpecifier.getText())) {
failures.push(new Lint.RuleFailure(sourceFile, moduleSpecifier.getStart(), moduleSpecifier.getStart() + moduleSpecifier.getWidth(), Rule.FAILURE_STRING, _this.ruleName));
}
});
return failures;
};
Rule.metadata = {
deprecationMessage: peer.v5 ? peer.v5NotSupportedMessage : undefined,
description: "Disallows importation from locations that depend upon 'rxjs-compat'.",
options: null,
optionsDescription: "Not configurable.",
requiresTypeInfo: false,
ruleName: "rxjs-no-compat",
type: "functionality",
typescriptOnly: false,
};
Rule.FAILURE_STRING = "'rxjs-compat' dependent import locations are forbidden";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var templateObject_1;