Skip to content

Commit ab1dbae

Browse files
committed
feat(assist): import organizer revamping
1 parent c7703a4 commit ab1dbae

File tree

87 files changed

+1937
-1987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1937
-1987
lines changed

biome.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
}
8282
}
8383
},
84-
"plugins": ["plugins/no-object-assign.grit"],
84+
"plugins": [
85+
"plugins/no-object-assign.grit"
86+
],
8587
"vcs": {
8688
"clientKind": "git",
8789
"enabled": true,

crates/biome_cli/tests/cases/included_files.rs

-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const FIX_AFTER: &str = "(1 >= 0)";
1313

1414
const UNORGANIZED: &str = r#"import * as something from "../something";
1515
import { lorem, foom, bar } from "foo";"#;
16-
const ORGANIZED: &str = r#"import { bar, foom, lorem } from "foo";
17-
import * as something from "../something";"#;
1816

1917
#[test]
2018
fn does_handle_only_included_files() {
@@ -199,10 +197,6 @@ fn does_not_handle_included_files_if_overridden_by_organize_imports() {
199197

200198
assert!(result.is_ok(), "run_cli returned {result:?}");
201199

202-
assert_file_contents(&fs, test2, ORGANIZED);
203-
204-
assert_file_contents(&fs, test, UNORGANIZED);
205-
206200
assert_cli_snapshot(SnapshotPayload::new(
207201
module_path!(),
208202
"does_not_handle_included_files_if_overridden_by_organize_imports",

crates/biome_cli/tests/cases/overrides_organize_imports.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use crate::run_cli;
2-
use crate::snap_test::{SnapshotPayload, assert_cli_snapshot, assert_file_contents};
2+
use crate::snap_test::{SnapshotPayload, assert_cli_snapshot};
33
use biome_console::BufferConsole;
44
use biome_fs::MemoryFileSystem;
55
use bpaf::Args;
66
use camino::Utf8Path;
77

88
const UNORGANIZED: &str = r#"import * as something from "../something";
99
import { lorem, foom, bar } from "foo";"#;
10-
const ORGANIZED: &str = r#"import { bar, foom, lorem } from "foo";
11-
import * as something from "../something";"#;
1210

1311
#[test]
1412
fn does_handle_included_file_and_disable_organize_imports() {
@@ -52,9 +50,6 @@ fn does_handle_included_file_and_disable_organize_imports() {
5250

5351
assert!(result.is_ok(), "run_cli returned {result:?}");
5452

55-
assert_file_contents(&fs, test2, UNORGANIZED);
56-
assert_file_contents(&fs, test, ORGANIZED);
57-
5853
assert_cli_snapshot(SnapshotPayload::new(
5954
module_path!(),
6055
"does_handle_included_file_and_disable_organize_imports",

crates/biome_cli/tests/commands/check.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,6 @@ fn applies_organize_imports_from_cli() {
16521652
let file_path = Utf8Path::new("check.js");
16531653
let content = r#"import * as something from "../something";
16541654
import { lorem, foom, bar } from "foo";
1655-
"#;
1656-
let expected = r#"import { bar, foom, lorem } from "foo";
1657-
import * as something from "../something";
16581655
"#;
16591656

16601657
fs.insert(file_path.into(), content.as_bytes());
@@ -1677,8 +1674,6 @@ import * as something from "../something";
16771674

16781675
assert!(result.is_ok(), "run_cli returned {result:?}");
16791676

1680-
assert_file_contents(&fs, file_path, expected);
1681-
16821677
assert_cli_snapshot(SnapshotPayload::new(
16831678
module_path!(),
16841679
"applies_organize_imports_from_cli",
@@ -1846,20 +1841,6 @@ fn check_stdin_write_unsafe_only_organize_imports() {
18461841

18471842
assert!(result.is_ok(), "run_cli returned {result:?}");
18481843

1849-
let message = console
1850-
.out_buffer
1851-
.first()
1852-
.expect("Console should have written a message");
1853-
1854-
let content = markup_to_string(markup! {
1855-
{message.content}
1856-
});
1857-
1858-
assert_eq!(
1859-
content,
1860-
"import _ from 'lodash'; import zod from 'zod'; function f() {return{}} class Foo {}"
1861-
);
1862-
18631844
assert_cli_snapshot(SnapshotPayload::new(
18641845
module_path!(),
18651846
"check_stdin_write_unsafe_only_organize_imports",

crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/check_stdin_write_successfully.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/biome_cli/tests/snap_test.rs
3-
expression: content
4-
snapshot_kind: text
3+
expression: redactor(content)
54
---
65
# Input messages
76

@@ -22,6 +21,7 @@ var foo: string = "";
2221
---
2322
import { something } from "file.astro";
2423
import { a } from "mod";
24+
2525
debugger;
2626
statement();
2727
var foo: string = "";

crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/check_stdin_write_unsafe_successfully.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/biome_cli/tests/snap_test.rs
3-
expression: content
4-
snapshot_kind: text
3+
expression: redactor(content)
54
---
65
# Input messages
76

@@ -22,6 +21,7 @@ var foo: string = "";
2221
---
2322
import { something } from "file.astro";
2423
import { a } from "mod";
24+
2525
statement();
2626
var foo: string = "";
2727
---

crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/check_stdin_write_successfully.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/biome_cli/tests/snap_test.rs
3-
expression: content
4-
snapshot_kind: text
3+
expression: redactor(content)
54
---
65
# Input messages
76

@@ -22,6 +21,7 @@ var foo: string = "";
2221
<script context="module" lang="ts">
2322
import Button from "./components/Button.svelte";
2423
import { Form } from "./components/Form.svelte";
24+
2525
debugger;
2626
statement();
2727
var foo: string = "";

crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/check_stdin_write_unsafe_successfully.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
source: crates/biome_cli/tests/snap_test.rs
3-
expression: content
4-
snapshot_kind: text
3+
expression: redactor(content)
54
---
65
# Input messages
76

@@ -22,6 +21,7 @@ var foo: string = "";
2221
<script context="module" lang="ts">
2322
import Button from "./components/Button.svelte";
2423
import { Form } from "./components/Form.svelte";
24+
2525
statement();
2626
var foo: string = "";
2727
</script>

crates/biome_cli/tests/snapshots/main_cases_overrides_organize_imports/does_handle_included_file_and_disable_organize_imports.snap

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: crates/biome_cli/tests/snap_test.rs
3-
expression: redactor(content)
43
snapshot_kind: text
54
---
65
## `biome.json`

crates/biome_cli/tests/snapshots/main_commands_check/check_stdin_write_unsafe_only_organize_imports.snap

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: crates/biome_cli/tests/snap_test.rs
3-
expression: content
3+
expression: redactor(content)
44
---
55
# Input messages
66

@@ -11,5 +11,6 @@ import zod from 'zod'; import _ from 'lodash'; function f() {return{}} class Foo
1111
# Emitted Messages
1212

1313
```block
14-
import _ from 'lodash'; import zod from 'zod'; function f() {return{}} class Foo {}
14+
import _ from 'lodash';
15+
import zod from 'zod'; function f() {return{}} class Foo {}
1516
```

0 commit comments

Comments
 (0)