Skip to content

Commit

Permalink
fix(cli): use correct list of evaluated paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Sep 16, 2024
1 parent 62efa7d commit 84b88d9
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 17 deletions.
26 changes: 19 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

## Unreleased

## v1.9.1 (2024-09-15)

### Analyzer

### CLI

#### Bug fixes

- `useEditorConfig` now loads the editorconfig when running `biome ci` [#3864](https://github.com/biomejs/biome/issues/3864). Contributed by @dyc3

- Revert [#3731](https://github.com/biomejs/biome/pull/3731) to fix broken quick fixes and code actions. Contributed by @nhedger
- Fix [#3917](https://github.com/biomejs/biome/issues/3917), where the fixed files were incorrectly computed. Contributed by @ematipico

### Configuration

Expand All @@ -33,6 +29,24 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

### Linter

### Parser

## v1.9.1 (2024-09-15)

### CLI

#### Bug fixes

- `useEditorConfig` now loads the editorconfig when running `biome ci` [#3864](https://github.com/biomejs/biome/issues/3864). Contributed by @dyc3

### Editors

#### Bug fixes

- Revert [#3731](https://github.com/biomejs/biome/pull/3731) to fix broken quick fixes and code actions. Contributed by @nhedger

### Linter

#### New Features

- Add [nursery/noProcessEnv](https://biomejs.dev/linter/rules/no-process-env/). Contributed by @unvalley
Expand All @@ -43,8 +57,6 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

- [noUndeclaredDependencies](https://biomejs.dev/linter/rules/no-undeclared-dependencies/) now ignores `@/` imports and recognizes type imports from Definitely Typed and `bun` imports. Contributed by @Conaclos

### Parser

## v1.9.0 (2024-09-12)

### Analyzer
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/src/execute/process_file/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ pub(crate) fn format_with_guard<'ctx>(
if output != input {
if should_write {
workspace_file.update_file(output)?;
Ok(FileStatus::Changed)
} else {
return Ok(FileStatus::Message(Message::Diff {
Ok(FileStatus::Message(Message::Diff {
file_name: workspace_file.path.display().to_string(),
old: input,
new: output,
diff_kind: DiffKind::Format,
}));
}))
}
Ok(FileStatus::Changed)
} else {
Ok(FileStatus::Unchanged)
}
Expand Down
8 changes: 5 additions & 3 deletions crates/biome_cli/src/execute/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn traverse_inputs(
}
}));

(start.elapsed(), dome.to_paths())
(start.elapsed(), ctx.evaluated_paths())
}

// struct DiagnosticsReporter<'ctx> {}
Expand Down Expand Up @@ -568,8 +568,10 @@ pub(crate) struct TraversalOptions<'ctx, 'app> {
impl<'ctx, 'app> TraversalOptions<'ctx, 'app> {
pub(crate) fn increment_changed(&self, path: &BiomePath) {
self.changed.fetch_add(1, Ordering::Relaxed);
let mut evaluated_paths = self.evaluated_paths.write().unwrap();
evaluated_paths.replace(path.to_written());
self.evaluated_paths
.write()
.unwrap()
.replace(path.to_written());
}
pub(crate) fn increment_unchanged(&self) {
self.unchanged.fetch_add(1, Ordering::Relaxed);
Expand Down
8 changes: 4 additions & 4 deletions crates/biome_cli/src/reporter/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Reporter for ConsoleReporter {
)]
struct EvaluatedPathsDiagnostic {
#[advice]
list: ListAdvice<String>,
advice: ListAdvice<String>,
}

#[derive(Debug, Diagnostic)]
Expand All @@ -48,7 +48,7 @@ struct EvaluatedPathsDiagnostic {
)]
struct FixedPathsDiagnostic {
#[advice]
list: ListAdvice<String>,
advice: ListAdvice<String>,
}

pub(crate) struct ConsoleReporterVisitor<'a>(pub(crate) &'a mut dyn Console);
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<'a> ReporterVisitor for ConsoleReporterVisitor<'a> {

fn report_handled_paths(&mut self, evaluated_paths: BTreeSet<BiomePath>) -> io::Result<()> {
let evaluated_paths_diagnostic = EvaluatedPathsDiagnostic {
list: ListAdvice {
advice: ListAdvice {
list: evaluated_paths
.iter()
.map(|p| p.display().to_string())
Expand All @@ -91,7 +91,7 @@ impl<'a> ReporterVisitor for ConsoleReporterVisitor<'a> {
};

let fixed_paths_diagnostic = FixedPathsDiagnostic {
list: ListAdvice {
advice: ListAdvice {
list: evaluated_paths
.iter()
.filter(|p| p.was_written())
Expand Down
33 changes: 33 additions & 0 deletions crates/biome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,39 @@ fn print_verbose() {
));
}

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

let file_path = Path::new("check.js");
fs.insert(file_path.into(), LINT_ERROR.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from(
[
("check"),
("--verbose"),
"--write",
file_path.as_os_str().to_str().unwrap(),
]
.as_slice(),
),
);

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

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"print_verbose_write",
fs,
console,
result,
));
}

#[test]
fn unsupported_file() {
let mut fs = MemoryFileSystem::default();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `check.js`

```js
while (true);

```

# Emitted Messages

```block
Checked 1 file in <TIME>. Fixed 1 file.
```

```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i Files processed:
- check.js
```

```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i Files fixed:
- check.js
```

0 comments on commit 84b88d9

Please sign in to comment.