File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,21 +87,12 @@ export function factory({ configSet }: TsCompilerInstance) {
8787 return statements
8888 }
8989
90- const pivot = statements [ 0 ]
91- const leftPart : _ts . Statement [ ] = [ ]
92- const rightPart : _ts . Statement [ ] = [ ]
93- for ( let i = 1 ; i < statements . length ; i ++ ) {
94- const currentStatement = statements [ i ]
95- if ( isJestGlobalImport ( currentStatement ) ) {
96- leftPart . push ( currentStatement )
97- } else {
98- isHoistableStatement ( currentStatement ) && ! isHoistableStatement ( pivot ) && ! isJestGlobalImport ( pivot )
99- ? leftPart . push ( currentStatement )
100- : rightPart . push ( currentStatement )
101- }
102- }
103-
104- return sortStatements ( leftPart ) . concat ( pivot , sortStatements ( rightPart ) )
90+ return statements . sort ( ( stmtA , stmtB ) =>
91+ isJestGlobalImport ( stmtA ) ||
92+ ( isHoistableStatement ( stmtA ) && ! isHoistableStatement ( stmtB ) && ! isJestGlobalImport ( stmtB ) )
93+ ? - 1
94+ : 1 ,
95+ )
10596 }
10697
10798 const createVisitor = ( ctx : _ts . TransformationContext , _ : _ts . SourceFile ) => {
You can’t perform that action at this time.
0 commit comments