From 67bbde35456be7002dda53d85ccbb87fc9a84bdf Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 17 Jan 2020 00:27:48 +0100 Subject: [PATCH] build: remove custom rxjs imports rule in favor of import-banlist rule (#18157) --- tools/tslint-rules/rxjsImportsRule.ts | 23 ----------------------- tslint.json | 5 +++-- 2 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 tools/tslint-rules/rxjsImportsRule.ts diff --git a/tools/tslint-rules/rxjsImportsRule.ts b/tools/tslint-rules/rxjsImportsRule.ts deleted file mode 100644 index c942e6c19701..000000000000 --- a/tools/tslint-rules/rxjsImportsRule.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as ts from 'typescript'; -import * as Lint from 'tslint'; - -/** - * Rule that ensures that all rxjs imports come only from `rxjs` and `rxjs/operators`. - */ -export class Rule extends Lint.Rules.AbstractRule { - apply(sourceFile: ts.SourceFile) { - return this.applyWithWalker(new Walker(sourceFile, this.getOptions())); - } -} - -class Walker extends Lint.RuleWalker { - visitImportDeclaration(node: ts.ImportDeclaration) { - const specifier = node.moduleSpecifier.getText().slice(1, -1); - - if (specifier.startsWith('rxjs') && specifier !== 'rxjs' && specifier !== 'rxjs/operators') { - this.addFailureAtNode(node, 'RxJS imports are only allowed from `rxjs` or `rxjs/operators`.'); - } - - super.visitImportDeclaration(node); - } -} diff --git a/tslint.json b/tslint.json index 6f2d590842cf..5386ab8c92da 100644 --- a/tslint.json +++ b/tslint.json @@ -114,7 +114,6 @@ "no-undecorated-class-with-ng-fields": true, "setters-after-getters": true, "ng-on-changes-property-access": true, - "rxjs-imports": true, "require-breaking-change-version": true, "class-list-signatures": true, "coercion-types": [true, @@ -182,7 +181,9 @@ ".*": "kebab-case" }], "no-unescaped-html-tag": true, - "import-blacklist": [true, ["^@schematics/angular/.*(ast).*"]] + // Ensures that all rxjs imports come only from `rxjs` and `rxjs/operators`. Also ensures + // that no AST utils from `@schematics/angular` are imported. These should be vendored. + "import-blacklist": [true, ["^@schematics/angular/.*(ast).*", "^rxjs(?!$|/operators$).*"]] }, "linterOptions": { "exclude": [