File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const SORT_STRATEGIES = [
19
19
"visibility" ,
20
20
"required-first" ,
21
21
"kind" ,
22
+ "internal-first" ,
22
23
] as const ;
23
24
24
25
export type SortStrategy = ( typeof SORT_STRATEGIES ) [ number ] ;
@@ -151,6 +152,9 @@ const sorts: Record<
151
152
kind ( a , b , { kindSortOrder } ) {
152
153
return kindSortOrder . indexOf ( a . kind ) < kindSortOrder . indexOf ( b . kind ) ;
153
154
} ,
155
+ "internal-first" ( a , b ) {
156
+ return ! a . flags . isExternal && b . flags . isExternal ;
157
+ } ,
154
158
} ;
155
159
156
160
export function getSortFunction ( opts : Options ) {
Original file line number Diff line number Diff line change @@ -209,6 +209,23 @@ describe("Sort", () => {
209
209
) ;
210
210
} ) ;
211
211
212
+ it ( "Should sort by internal first" , ( ) => {
213
+ const arr = [
214
+ new DeclarationReflection ( "a" , ReflectionKind . Function ) ,
215
+ new DeclarationReflection ( "b" , ReflectionKind . Function ) ,
216
+ new DeclarationReflection ( "c" , ReflectionKind . Function ) ,
217
+ ] ;
218
+ arr [ 0 ] . setFlag ( ReflectionFlag . External , true ) ;
219
+ arr [ 1 ] . setFlag ( ReflectionFlag . External , false ) ;
220
+ arr [ 2 ] . setFlag ( ReflectionFlag . External , true ) ;
221
+
222
+ sortReflections ( arr , [ "internal-first" ] ) ;
223
+ equal (
224
+ arr . map ( ( r ) => r . name ) ,
225
+ [ "b" , "a" , "c" ] ,
226
+ ) ;
227
+ } ) ;
228
+
212
229
it ( "Should sort with multiple strategies" , ( ) => {
213
230
resetReflectionID ( ) ;
214
231
const arr = [
You can’t perform that action at this time.
0 commit comments