From 0ac1b5dbca6df0142547918a4b415988b4f69637 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 21 Jan 2020 21:57:19 -0700 Subject: [PATCH 1/2] Enable esModuleInterop --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 60c6873..a38fbb5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "compilerOptions": { "declaration": true, + "esModuleInterop": true, "lib": ["es2017"], "module": "commonjs", "moduleResolution": "node", From c3d0fd578506aeb6d83d04f539b8d3e8078d4651 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 21 Jan 2020 21:59:42 -0700 Subject: [PATCH 2/2] Check option against first section of moduleName --- src/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0648666..bac4adb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,5 @@ +import path from 'path' + import { IStyleAPI, IStyleItem } from 'import-sort-style' declare type ImportType = 'import' | 'require' | 'import-equals' | 'import-type' @@ -41,14 +43,16 @@ export default function( let knownFirstparty = options.knownFirstparty || [] function isFrameworkModule(imported: IImport) { - return knownFramework.some((prefix) => - imported.moduleName.startsWith(prefix), + let [base] = imported.moduleName.split(path.sep) + return knownFramework.some((prefix: string) => + RegExp(`${prefix}$`).test(base), ) } function isFirstPartyModule(imported: IImport) { - return knownFirstparty.some((prefix) => - imported.moduleName.startsWith(prefix), + let [base] = imported.moduleName.split(path.sep) + return knownFirstparty.some((prefix: string) => + RegExp(`${prefix}$`).test(base), ) }