Skip to content

Commit

Permalink
fix(cli): correctly apply import sorting on --apply (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Sep 16, 2023
1 parent 2360476 commit b4dadd8
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 359 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom
### Parser
### VSCode

## 1.2.2 (2023-09-16)

### CLI

#### Bug fixes

- Fix a condition where import sorting wasn't applied when running `biome check --apply`


## 1.2.1 (2023-09-15)

### Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) fn organize_imports_with_guard<'ctx>(

let input = workspace_file.input()?;
if sorted.code != input {
if ctx.execution.is_check_apply_unsafe() {
if ctx.execution.is_check_apply_unsafe() || ctx.execution.is_check_apply() {
workspace_file.update_file(sorted.code)?;
} else {
return Ok(FileStatus::Message(Message::Diff {
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ import * as something from "../something";
}

#[test]
fn shows_organize_imports_diff_on_check_apply() {
fn should_organize_imports_diff_on_check() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

Expand Down Expand Up @@ -1656,7 +1656,7 @@ import * as something from "../something";
),
);

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

let mut file = fs
.open(file_path)
Expand All @@ -1672,7 +1672,7 @@ import * as something from "../something";

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"shows_organize_imports_diff_on_check_apply",
"should_organize_imports_diff_on_check",
fs,
console,
result,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `biome.json`

```json
{ "organizeImports": { "enabled": true } }
```

## `check.js`

```js
import { bar, foom, lorem } from "foo";
import * as something from "../something";

```

# Emitted Messages

```block
Fixed 1 file(s) in <TIME>
```


This file was deleted.

Loading

0 comments on commit b4dadd8

Please sign in to comment.