Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path'

import { IStyleAPI, IStyleItem } from 'import-sort-style'

declare type ImportType = 'import' | 'require' | 'import-equals' | 'import-type'
Expand Down Expand Up @@ -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),
)
}

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compilerOptions": {
"declaration": true,

"esModuleInterop": true,
"lib": ["es2017"],
"module": "commonjs",
"moduleResolution": "node",
Expand Down