Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Import-blacklist: simplify check for if module has blacklisted imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanresnick committed Jun 20, 2018
1 parent 805769d commit b98e620
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/rules/importBlacklistRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { findImports, ImportKind, isExportDeclaration, isImportDeclaration, isNamedImports } from "tsutils";
import * as ts from "typescript";
import * as Lint from "../index";
import { hasOwnProperty } from "../utils";

export class Rule extends Lint.Rules.AbstractRule {
/* tslint:disable:object-literal-sort-keys */
Expand Down Expand Up @@ -114,7 +113,7 @@ function walk(ctx: Lint.WalkContext<string[]>) {
}
return acc;
},
{},
Object.create(null),
);

for (const name of findImports(ctx.sourceFile, ImportKind.All)) {
Expand All @@ -123,7 +122,7 @@ function walk(ctx: Lint.WalkContext<string[]>) {
const bansForModule = bannedImports[importedModule];

// Check if at least some imports from this module are banned.
if (hasOwnProperty(bannedImports, importedModule)) {
if (bansForModule) {
// If importing this module is totally banned, we can error now,
// without determining whether the user is importing the whole
// module or named exports.
Expand Down

0 comments on commit b98e620

Please sign in to comment.