Skip to content

Commit 0abe461

Browse files
committed
test(formatter): Add tests for sort-imports
1 parent eb52529 commit 0abe461

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/oxc_formatter/tests/ir_transform/sort_imports.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,33 @@ import type { T1, T2 } from "t";
375375
import type { V } from "v";
376376
const X = 1;
377377
import type { T1, T2 } from "t";
378+
"#,
379+
);
380+
// Still works with multiple import groups
381+
assert_format(
382+
r#"
383+
import b from "b";
384+
import a from "a";
385+
const X = 1;
386+
import d from "d";
387+
import c from "c";
388+
export const Y = 2;
389+
import f from "f";
390+
import e from "e";
391+
"#,
392+
&FormatOptions {
393+
experimental_sort_imports: Some(SortImports::default()),
394+
..Default::default()
395+
},
396+
r#"
397+
import a from "a";
398+
import b from "b";
399+
const X = 1;
400+
import c from "c";
401+
import d from "d";
402+
export const Y = 2;
403+
import e from "e";
404+
import f from "f";
378405
"#,
379406
);
380407
}

0 commit comments

Comments
 (0)