File tree Expand file tree Collapse file tree
tests/specs/source/organizeImports Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @biomejs/biome " : patch
3+ ---
4+
5+ Fixed [ #6492 ] ( https://github.com/biomejs/biome/issues/6492 ) . The
6+ ` organizeImports ` assist action no longer duplicates a comment at the start of
7+ the file when ` :BLANK_LINE: ` precedes the first import group.
Original file line number Diff line number Diff line change @@ -945,9 +945,11 @@ impl Rule for OrganizeImports {
945945 } ;
946946 let mut new_item = new_item. into_syntax ( ) ;
947947 let old_item = old_item. into_node ( ) ?;
948- let blank_line_separated_groups = options
949- . groups
950- . separated_by_blank_line ( prev_group, key. group ) ;
948+ let blank_line_separated_groups = index != 0
949+ && options
950+ . groups
951+ . separated_by_blank_line ( prev_group, key. group ) ;
952+ prev_group = key. group ;
951953 // Don't make any change if it is the same node and no change have to be done
952954 if !blank_line_separated_groups && index == key. slot_index && !was_merged {
953955 continue ;
@@ -1001,7 +1003,6 @@ impl Rule for OrganizeImports {
10011003 new_item = new_item. prepend_trivia_pieces ( newline) ?;
10021004 }
10031005 mutation. replace_element_discard_trivia ( old_item. into ( ) , new_item. into ( ) ) ;
1004- prev_group = key. group ;
10051006 }
10061007 }
10071008 }
Original file line number Diff line number Diff line change 1+ // some comment
2+ import react from "@vitejs/plugin-react" ;
3+ import svgr from "vite-plugin-svgr" ;
4+ import { defineConfig } from "vite" ;
5+ import tsconfigPaths from "vite-tsconfig-paths" ;
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / biome_js_analyze / tests / spec_tests .rs
3+ expression : issue6492 .js
4+ -- -
5+ # Input
6+ ` ` ` js
7+ // some comment
8+ import react from "@vitejs/plugin-react";
9+ import svgr from "vite-plugin-svgr";
10+ import { defineConfig } from "vite";
11+ import tsconfigPaths from "vite-tsconfig-paths";
12+
13+ ` ` `
14+
15+ # Diagnostics
16+ ` ` `
17+ issue6492.js:2:1 assist/source/organizeImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
18+
19+ i The imports and exports are not sorted.
20+
21+ 1 │ // some comment
22+ > 2 │ import react from "@vitejs/plugin-react";
23+ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+ 3 │ import svgr from "vite-plugin-svgr";
25+ 4 │ import { defineConfig } from "vite";
26+
27+ i Safe fix: Organize Imports (Biome)
28+
29+ 1 1 │ // some comment
30+ 2 2 │ import react from "@vitejs/plugin-react";
31+ 3 │ - import·svgr·from·"vite-plugin-svgr";
32+ 4 │ - import·{ ·defineConfig ·} ·from·"vite";
33+ 3 │ + import·{ ·defineConfig ·} ·from·"vite";
34+ 4 │ + import·svgr·from·"vite-plugin-svgr";
35+ 5 5 │ import tsconfigPaths from "vite-tsconfig-paths";
36+ 6 6 │
37+
38+
39+ ` ` `
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " https://biomejs.dev/schemas/2.0.4/schema.json" ,
3+ "assist" : {
4+ "enabled" : true ,
5+ "actions" : {
6+ "source" : {
7+ "organizeImports" : {
8+ "level" : " on" ,
9+ "options" : {
10+ "groups" : [
11+ [" react*" , " react*/*" ],
12+ " :BLANK_LINE:"
13+ ]
14+ }
15+ }
16+ }
17+ }
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments