Skip to content

Commit 83ede52

Browse files
committed
Fix group prefix check functions
1 parent 90f15b0 commit 83ede52

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/index.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ interface IImport {
1818
namedMembers: NamedMember[]
1919
}
2020

21-
export default function (styleApi: IStyleAPI, options?: any): Array<IStyleItem> {
21+
export default function (
22+
styleApi: IStyleAPI,
23+
file?: string,
24+
options?: any,
25+
): Array<IStyleItem> {
2226
const {
2327
alias,
2428
and,
@@ -35,14 +39,14 @@ export default function (styleApi: IStyleAPI, options?: any): Array<IStyleItem>
3539
const { knownFramework, knownFirstparty } = options
3640

3741
function isFrameworkModule (imported: IImport) {
38-
return knownFramework.map((module) =>
39-
imported.moduleName.startsWith(module),
42+
return knownFramework.some((prefix) =>
43+
imported.moduleName.startsWith(prefix),
4044
)
4145
}
4246

4347
function isFirstPartyModule (imported: IImport) {
44-
return knownFirstparty.map((module) =>
45-
imported.moduleName.startsWith(module),
48+
return knownFirstparty.some((prefix) =>
49+
imported.moduleName.startsWith(prefix),
4650
)
4751
}
4852

@@ -74,10 +78,14 @@ export default function (styleApi: IStyleAPI, options?: any): Array<IStyleItem>
7478

7579
/**
7680
* Known framework modules.
77-
* @example import … from '@ember/foo'
81+
* @example import … from '@scope/foo'
7882
*/
7983
{
80-
match: isFrameworkModule,
84+
match: and(
85+
isAbsoluteModule,
86+
isFrameworkModule,
87+
not(isFirstPartyModule),
88+
),
8189
sort: moduleName(naturally),
8290
sortNamedMembers: alias(unicode),
8391
},
@@ -100,10 +108,14 @@ export default function (styleApi: IStyleAPI, options?: any): Array<IStyleItem>
100108

101109
/**
102110
* Known first-party modules.
103-
* @example import … from '@ember/foo'
111+
* @example import … from 'project/foo'
104112
*/
105113
{
106-
match: isFirstPartyModule,
114+
match: and(
115+
isAbsoluteModule,
116+
isFirstPartyModule,
117+
not(isFrameworkModule),
118+
),
107119
sort: moduleName(naturally),
108120
sortNamedMembers: alias(unicode),
109121
},

0 commit comments

Comments
 (0)