Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/social-hornets-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@biomejs/biome": minor
---

Added the ability to show severity `Information` diagnostics in reporter outputs.

If one or more rules are triggered, and they are configured to emit an `Information` diagnostic, now they're counted in the final output:

```bash
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
2 changes: 1 addition & 1 deletion .changeset/warm-insects-dress.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The option `lineEnding` now has a variant called `auto` to match the operating system's expected
line-ending style: on Windows, this will be CRLF (`\r\n`), and on macOS / Linux, this will
be LF (`\n`).
be LF (`\n`).

This allows for cross-platform projects that use Biome not to have to
force one option or the other, which aligns better with Git's default behavior
Expand Down
16 changes: 16 additions & 0 deletions crates/biome_cli/src/execute/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub(crate) fn traverse(

let errors = printer.errors();
let warnings = printer.warnings();
let infos = printer.infos();
let changed = changed.load(Ordering::Relaxed);
let unchanged = unchanged.load(Ordering::Relaxed);
let matches = matches.load(Ordering::Relaxed);
Expand All @@ -116,6 +117,7 @@ pub(crate) fn traverse(
errors,
matches,
warnings,
infos,
skipped,
suggested_fixes_skipped,
diagnostics_not_printed,
Expand Down Expand Up @@ -165,6 +167,9 @@ struct DiagnosticsPrinter<'ctx> {
/// Mutable reference to a boolean flag tracking whether the console thread
/// printed any warnings-level message
warnings: AtomicU32,
/// Mutable reference to a boolean flag tracking whether the console thread
/// printed any info-level message
infos: AtomicU32,
/// Whether the console thread should print diagnostics in verbose mode
verbose: bool,
/// The diagnostic level the console thread should print
Expand All @@ -183,6 +188,7 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
Self {
errors: AtomicU32::new(0),
warnings: AtomicU32::new(0),
infos: AtomicU32::new(0),
remaining_diagnostics: AtomicU32::new(0),
execution,
diagnostic_level: Severity::Hint,
Expand Down Expand Up @@ -218,6 +224,10 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
self.warnings.load(Ordering::Relaxed)
}

fn infos(&self) -> u32 {
self.infos.load(Ordering::Relaxed)
}

fn not_printed_diagnostics(&self) -> u32 {
self.not_printed_diagnostics.load(Ordering::Relaxed)
}
Expand Down Expand Up @@ -284,6 +294,9 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
if err.severity() == Severity::Warning {
self.warnings.fetch_add(1, Ordering::Relaxed);
}
// if err.severity() == Severity::Information {
// self.infos.fetch_add(1, Ordering::Relaxed);
// }
if let Some(Resource::File(file_path)) = location.resource.as_ref() {
// Retrieves the file name from the file ID cache, if it's a miss
// flush entries from the interner channel until it's found
Expand Down Expand Up @@ -340,6 +353,9 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
if severity == Severity::Warning {
self.warnings.fetch_add(1, Ordering::Relaxed);
}
if severity == Severity::Information {
self.infos.fetch_add(1, Ordering::Relaxed);
}

let should_print = self.should_print();

Expand Down
1 change: 1 addition & 0 deletions crates/biome_cli/src/reporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct TraversalSummary {
pub scanner_duration: Option<Duration>,
pub errors: u32,
pub warnings: u32,
pub infos: u32,
pub skipped: usize,
pub suggested_fixes_skipped: u32,
pub diagnostics_not_printed: u32,
Expand Down
49 changes: 33 additions & 16 deletions crates/biome_cli/src/reporter/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,45 @@ impl fmt::Display for ConsoleTraversalSummary<'_> {
let detail = SummaryDetail(mode, summary.changed);
fmt.write_markup(markup!(<Info>{total}{detail}</Info>))?;

if summary.errors > 0 {
if summary.errors == 1 {
fmt.write_markup(markup!("\n"<Error>"Found "{summary.errors}" error."</Error>))?;
} else {
fmt.write_markup(markup!("\n"<Error>"Found "{summary.errors}" errors."</Error>))?;
}
}
if summary.warnings > 0 {
if summary.warnings == 1 {
fmt.write_markup(markup!("\n"<Warn>"Found "{summary.warnings}" warning."</Warn>))?;
} else {
fmt.write_markup(markup!("\n"<Warn>"Found "{summary.warnings}" warnings."</Warn>))?;
}
}

// The search emits info diagnostics, so we use if control-flow to print a different message
if let TraversalMode::Search { .. } = mode {
if summary.matches == 1 {
fmt.write_markup(markup!(" "<Info>"Found "{summary.matches}" match."</Info>))?
} else {
fmt.write_markup(markup!(" "<Info>"Found "{summary.matches}" matches."</Info>))?
};
};
} else {
if summary.errors > 0 {
if summary.errors == 1 {
fmt.write_markup(
markup!("\n"<Error>"Found "{summary.errors}" error."</Error>),
)?;
} else {
fmt.write_markup(
markup!("\n"<Error>"Found "{summary.errors}" errors."</Error>),
)?;
}
}
if summary.warnings > 0 {
if summary.warnings == 1 {
fmt.write_markup(
markup!("\n"<Warn>"Found "{summary.warnings}" warning."</Warn>),
)?;
} else {
fmt.write_markup(
markup!("\n"<Warn>"Found "{summary.warnings}" warnings."</Warn>),
)?;
}
}

if summary.infos > 0 {
if summary.infos == 1 {
fmt.write_markup(markup!("\n"<Info>"Found "{summary.infos}" info."</Info>))?;
} else {
fmt.write_markup(markup!("\n"<Info>"Found "{summary.infos}" infos."</Info>))?;
}
}
}
Ok(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ file.json:1:1 assist/source/useSortedKeys FIXABLE ━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ file1.js:1:1 lint/complexity/useFlatMap FIXABLE ━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ The --json option is unstable/experimental and its output might change between p
```

```block
{"summary":{"changed":1,"unchanged":0,"matches":0,"errors":0,"warnings":0,"skipped":0,"suggestedFixesSkipped":0,"diagnosticsNotPrinted":0},"diagnostics":[],"command":"check"}
{"summary":{"changed":1,"unchanged":0,"matches":0,"errors":0,"warnings":0,"infos":0,"skipped":0,"suggestedFixesSkipped":0,"diagnosticsNotPrinted":0},"diagnostics":[],"command":"check"}
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The --json option is unstable/experimental and its output might change between p
"matches": 0,
"errors": 0,
"warnings": 0,
"infos": 0,
"skipped": 0,
"suggestedFixesSkipped": 0,
"diagnosticsNotPrinted": 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ fix.js format ━━━━━━━━━━━━━━━━━━━━━━
```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 error.
Found 1 info.
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: redactor(content)
snapshot_kind: text
---
## `format.js`

Expand All @@ -27,5 +26,5 @@ The --json option is unstable/experimental and its output might change between p
```

```block
{"summary":{"changed":0,"unchanged":1,"matches":0,"errors":1,"warnings":0,"skipped":0,"suggestedFixesSkipped":0,"diagnosticsNotPrinted":0},"diagnostics":[{"category":"format","severity":"error","description":"Formatter would have printed the following content:","message":[{"elements":[],"content":"Formatter would have printed the following content:"}],"advices":{"advices":[{"diff":{"dictionary":" statement();\n","ops":[{"diffOp":{"delete":{"range":[0,2]}}},{"diffOp":{"equal":{"range":[2,12]}}},{"diffOp":{"delete":{"range":[0,2]}}},{"diffOp":{"equal":{"range":[12,13]}}},{"diffOp":{"delete":{"range":[0,2]}}},{"diffOp":{"insert":{"range":[13,15]}}}]}}]},"verboseAdvices":{"advices":[]},"location":{"path":{"file":"format.js"},"span":null,"sourceCode":" statement( ) "},"tags":[],"source":null}],"command":"format"}
{"summary":{"changed":0,"unchanged":1,"matches":0,"errors":1,"warnings":0,"infos":0,"skipped":0,"suggestedFixesSkipped":0,"diagnosticsNotPrinted":0},"diagnostics":[{"category":"format","severity":"error","description":"Formatter would have printed the following content:","message":[{"elements":[],"content":"Formatter would have printed the following content:"}],"advices":{"advices":[{"diff":{"dictionary":" statement();\n","ops":[{"diffOp":{"delete":{"range":[0,2]}}},{"diffOp":{"equal":{"range":[2,12]}}},{"diffOp":{"delete":{"range":[0,2]}}},{"diffOp":{"equal":{"range":[12,13]}}},{"diffOp":{"delete":{"range":[0,2]}}},{"diffOp":{"insert":{"range":[13,15]}}}]}}]},"verboseAdvices":{"advices":[]},"location":{"path":{"file":"format.js"},"span":null,"sourceCode":" statement( ) "},"tags":[],"source":null}],"command":"format"}
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: redactor(content)
snapshot_kind: text
---
## `format.js`

Expand Down Expand Up @@ -34,6 +33,7 @@ The --json option is unstable/experimental and its output might change between p
"matches": 0,
"errors": 1,
"warnings": 0,
"infos": 0,
"skipped": 0,
"suggestedFixesSkipped": 0,
"diagnosticsNotPrinted": 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `biome.json`

Expand Down Expand Up @@ -42,4 +42,5 @@ file.js:1:1 lint/suspicious/noDebugger FIXABLE ━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
snapshot_kind: text
expression: redactor(content)
---
## `biome.json`

Expand Down Expand Up @@ -48,4 +47,5 @@ check.js:3:21 lint/style/useNamingConvention ━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
snapshot_kind: text
expression: redactor(content)
---
## `biome.json`

Expand Down Expand Up @@ -39,4 +38,5 @@ check.js:2:21 lint/style/useNamingConvention ━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ src/index.ts:5:1 lint/nursery/noFloatingPromises ━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ src/index.ts:5:1 lint/nursery/noFloatingPromises ━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ fix.js:3:1 lint/complexity/useFlatMap FIXABLE ━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 info.
```
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ biome.json format ━━━━━━━━━━━━━━━━━━━━
```block
Checked 1 file in <TIME>. No fixes applied.
Found 1 error.
Found 1 info.
```
Loading