From 379c397d031f5b2c0e6936df2fc9b9c48b576937 Mon Sep 17 00:00:00 2001 From: Fernando Maia Date: Thu, 23 Apr 2020 13:43:18 -0300 Subject: [PATCH] fix: enhance alias detection fix #4 --- src/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index aad80af..730c8a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ -import { IStyleAPI, IStyleItem } from 'import-sort-style'; - import { IImport } from 'import-sort-parser'; +import { IStyleAPI, IStyleItem } from 'import-sort-style'; export interface Options { alias: string[]; @@ -8,7 +7,9 @@ export interface Options { const hasAlias = (aliases: string[]) => (imported: IImport): boolean => aliases.some( - (alias: string): boolean => imported.moduleName.indexOf(alias) === 0 + (alias: string): boolean => + imported.moduleName === alias || + imported.moduleName.indexOf(`${alias}/`) === 0 ); export default (