diff --git a/crates/rome_cli/src/commands/help.rs b/crates/rome_cli/src/commands/help.rs
index 9d4ea3c706a7..a4f015407d9f 100644
--- a/crates/rome_cli/src/commands/help.rs
+++ b/crates/rome_cli/src/commands/help.rs
@@ -37,6 +37,7 @@ const CHECK: Markup = markup! {
""--apply"" Apply safe fixes
""--apply-suggested"" Apply safe and suggested fixes
""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 20)
+ ""--verbose"" Print additional verbose advices on diagnostics
"
};
@@ -63,7 +64,8 @@ const CI: Markup = markup! {
""OPTIONS:""
""--formatter-enabled"" Allow to enable or disable the formatter check. (default: true)
""--linter-enabled"" Allow to enable or disable the linter check. (default: true)
- ""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 50)"
+ ""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 50)
+ ""--verbose"" Print additional verbose advices on diagnostics"
{FORMAT_OPTIONS}
};
@@ -78,7 +80,8 @@ const FORMAT: Markup = markup! {
""OPTIONS:""
""--write"" Edit the files in place (beware!) instead of printing the diff to the console
""--skip-errors"" Skip over files containing syntax errors instead of emitting an error diagnostic.
- ""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 50)"
+ ""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 50)
+ ""--verbose"" Print additional verbose advices on diagnostics"
{FORMAT_OPTIONS}
"""--stdin-file-path "" A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js
"
diff --git a/crates/rome_cli/src/traversal.rs b/crates/rome_cli/src/traversal.rs
index 748069572216..d9b1237ee370 100644
--- a/crates/rome_cli/src/traversal.rs
+++ b/crates/rome_cli/src/traversal.rs
@@ -57,6 +57,8 @@ impl fmt::Display for CheckResult {
pub(crate) fn traverse(execution: Execution, mut session: CliSession) -> Result<(), Termination> {
init_thread_pool();
+ let verbose = session.args.contains("--verbose");
+
// Check that at least one input file / directory was specified in the command line
let mut inputs = vec![];
@@ -116,6 +118,7 @@ pub(crate) fn traverse(execution: Execution, mut session: CliSession) -> Result<
remaining_diagnostics: &remaining_diagnostics,
errors: &mut errors,
report: &mut report,
+ verbose,
});
})
.expect("failed to spawn console thread");
@@ -262,6 +265,8 @@ struct ProcessMessagesOptions<'ctx> {
/// Mutable handle to a [Report] instance the console thread should write
/// stats into
report: &'ctx mut Report,
+ /// Whether the console thread should print diagnostics in verbose mode
+ verbose: bool,
}
#[derive(Debug, Diagnostic)]
@@ -328,6 +333,7 @@ fn process_messages(options: ProcessMessagesOptions) {
remaining_diagnostics,
errors,
report,
+ verbose,
} = options;
let mut paths = HashMap::new();
@@ -413,7 +419,7 @@ fn process_messages(options: ProcessMessagesOptions) {
if mode.should_report_to_terminal() {
if should_print {
console.error(markup! {
- {PrintDiagnostic(&err)}
+ {PrintDiagnostic(&err, verbose)}
});
}
} else {
@@ -460,7 +466,7 @@ fn process_messages(options: ProcessMessagesOptions) {
let diag = diag.with_file_path(&name).with_file_source_code(&content);
console.error(markup! {
- {PrintDiagnostic(&diag)}
+ {PrintDiagnostic(&diag, verbose)}
});
}
} else {
@@ -486,7 +492,7 @@ fn process_messages(options: ProcessMessagesOptions) {
let diag =
diag.with_file_path(&name).with_file_source_code(&content);
console.error(markup! {
- {PrintDiagnostic(&diag)}
+ {PrintDiagnostic(&diag, verbose)}
});
}
} else {
@@ -536,7 +542,7 @@ fn process_messages(options: ProcessMessagesOptions) {
};
console.error(markup! {
- {PrintDiagnostic(&diag)}
+ {PrintDiagnostic(&diag, verbose)}
});
} else {
let diag = FormatDiffDiagnostic {
@@ -548,7 +554,7 @@ fn process_messages(options: ProcessMessagesOptions) {
};
console.error(markup! {
- {PrintDiagnostic(&diag)}
+ {PrintDiagnostic(&diag, verbose)}
});
}
}
diff --git a/crates/rome_cli/tests/commands/check.rs b/crates/rome_cli/tests/commands/check.rs
index d5f9d47ae5c9..4052a2357bd9 100644
--- a/crates/rome_cli/tests/commands/check.rs
+++ b/crates/rome_cli/tests/commands/check.rs
@@ -992,3 +992,35 @@ fn no_supported_file_found() {
result,
));
}
+
+#[test]
+fn print_verbose() {
+ 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),
+ DynRef::Borrowed(&mut console),
+ Arguments::from_vec(vec![
+ OsString::from("check"),
+ OsString::from("--verbose"),
+ file_path.as_os_str().into(),
+ ]),
+ );
+
+ match result {
+ Err(Termination::CheckError) => {}
+ _ => panic!("run_cli returned {result:?} for a failed CI check, expected an error"),
+ }
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "print_verbose",
+ fs,
+ console,
+ result,
+ ));
+}
diff --git a/crates/rome_cli/tests/commands/ci.rs b/crates/rome_cli/tests/commands/ci.rs
index 8f5764435c89..c1fd63929dec 100644
--- a/crates/rome_cli/tests/commands/ci.rs
+++ b/crates/rome_cli/tests/commands/ci.rs
@@ -569,3 +569,35 @@ fn max_diagnostics() {
assert_eq!(console.out_buffer.len(), 11);
}
+
+#[test]
+fn print_verbose() {
+ let mut fs = MemoryFileSystem::default();
+
+ let file_path = Path::new("ci.js");
+ fs.insert(file_path.into(), LINT_ERROR.as_bytes());
+
+ let mut console = BufferConsole::default();
+ let result = run_cli(
+ DynRef::Borrowed(&mut fs),
+ DynRef::Borrowed(&mut console),
+ Arguments::from_vec(vec![
+ OsString::from("ci"),
+ OsString::from("--verbose"),
+ file_path.as_os_str().into(),
+ ]),
+ );
+
+ match &result {
+ Err(Termination::CheckError) => {}
+ _ => panic!("run_cli returned {result:?} for a failed CI check, expected an error"),
+ }
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "print_verbose",
+ fs,
+ console,
+ result,
+ ));
+}
diff --git a/crates/rome_cli/tests/commands/format.rs b/crates/rome_cli/tests/commands/format.rs
index f3f17086721d..82e8b433dbe7 100644
--- a/crates/rome_cli/tests/commands/format.rs
+++ b/crates/rome_cli/tests/commands/format.rs
@@ -1350,3 +1350,32 @@ fn no_supported_file_found() {
result,
));
}
+
+#[test]
+fn print_verbose() {
+ let mut fs = MemoryFileSystem::default();
+ let mut console = BufferConsole::default();
+
+ let file_path = Path::new("format.js");
+ fs.insert(file_path.into(), UNFORMATTED.as_bytes());
+
+ let result = run_cli(
+ DynRef::Borrowed(&mut fs),
+ DynRef::Borrowed(&mut console),
+ Arguments::from_vec(vec![
+ OsString::from("format"),
+ OsString::from("--verbose"),
+ file_path.as_os_str().into(),
+ ]),
+ );
+
+ assert!(result.is_ok(), "run_cli returned {result:?}");
+
+ assert_cli_snapshot(SnapshotPayload::new(
+ module_path!(),
+ "print_verbose",
+ fs,
+ console,
+ result,
+ ));
+}
diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/print_verbose.snap b/crates/rome_cli/tests/snapshots/main_commands_check/print_verbose.snap
new file mode 100644
index 000000000000..038f2f42a740
--- /dev/null
+++ b/crates/rome_cli/tests/snapshots/main_commands_check/print_verbose.snap
@@ -0,0 +1,56 @@
+---
+source: crates/rome_cli/tests/snap_test.rs
+expression: content
+---
+## `check.js`
+
+```js
+for(;true;);
+
+```
+
+# Termination Message
+
+```block
+some errors were emitted while running checks
+```
+
+# Emitted Messages
+
+```block
+check.js:1:1 lint/correctness/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ × Use while loops instead of for loops.
+
+ > 1 │ for(;true;);
+ │ ^^^^^^^^^^^
+ 2 │
+
+ i Suggested fix: Use a while loop
+
+ 1 │ - for(;true;);
+ 1 │ + while·(true);
+ 2 2 │
+
+
+```
+
+```block
+check.js:1:1 lint/style/useBlockStatements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ × Block statements are preferred in this position.
+
+ > 1 │ for(;true;);
+ │ ^^^^^^^^^^^^
+ 2 │
+
+ i Suggested fix: Wrap the statement with a `JsBlockStatement`
+
+ 1 │ - for(;true;);
+ 1 │ + for(;true;)·{}
+ 2 2 │
+
+
+```
+
+
diff --git a/crates/rome_cli/tests/snapshots/main_commands_ci/print_verbose.snap b/crates/rome_cli/tests/snapshots/main_commands_ci/print_verbose.snap
new file mode 100644
index 000000000000..2c559500041b
--- /dev/null
+++ b/crates/rome_cli/tests/snapshots/main_commands_ci/print_verbose.snap
@@ -0,0 +1,56 @@
+---
+source: crates/rome_cli/tests/snap_test.rs
+expression: content
+---
+## `ci.js`
+
+```js
+for(;true;);
+
+```
+
+# Termination Message
+
+```block
+some errors were emitted while running checks
+```
+
+# Emitted Messages
+
+```block
+ci.js:1:1 lint/correctness/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ × Use while loops instead of for loops.
+
+ > 1 │ for(;true;);
+ │ ^^^^^^^^^^^
+ 2 │
+
+ i Suggested fix: Use a while loop
+
+ 1 │ - for(;true;);
+ 1 │ + while·(true);
+ 2 2 │
+
+
+```
+
+```block
+ci.js:1:1 lint/style/useBlockStatements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ × Block statements are preferred in this position.
+
+ > 1 │ for(;true;);
+ │ ^^^^^^^^^^^^
+ 2 │
+
+ i Suggested fix: Wrap the statement with a `JsBlockStatement`
+
+ 1 │ - for(;true;);
+ 1 │ + for(;true;)·{}
+ 2 2 │
+
+
+```
+
+
diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/print_verbose.snap b/crates/rome_cli/tests/snapshots/main_commands_format/print_verbose.snap
new file mode 100644
index 000000000000..3136b73e0984
--- /dev/null
+++ b/crates/rome_cli/tests/snapshots/main_commands_format/print_verbose.snap
@@ -0,0 +1,25 @@
+---
+source: crates/rome_cli/tests/snap_test.rs
+expression: content
+---
+## `format.js`
+
+```js
+ statement( )
+```
+
+# Emitted Messages
+
+```block
+format.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ i Formatter would have printed the following content:
+
+ 1 │ - ··statement(··)··
+ 1 │ + statement();
+ 2 │ +
+
+
+```
+
+
diff --git a/crates/rome_diagnostics/examples/cli.rs b/crates/rome_diagnostics/examples/cli.rs
index 18014358c883..5a8776484ee7 100644
--- a/crates/rome_diagnostics/examples/cli.rs
+++ b/crates/rome_diagnostics/examples/cli.rs
@@ -59,5 +59,5 @@ pub fn main() {
},
};
- EnvConsole::default().error(markup!({ PrintDiagnostic(&diag) }));
+ EnvConsole::default().error(markup!({ PrintDiagnostic(&diag, true) }));
}
diff --git a/crates/rome_diagnostics/examples/fs.rs b/crates/rome_diagnostics/examples/fs.rs
index 5ad3ec67fdf4..2a6b51cc083c 100644
--- a/crates/rome_diagnostics/examples/fs.rs
+++ b/crates/rome_diagnostics/examples/fs.rs
@@ -68,5 +68,5 @@ pub fn main() {
},
};
- EnvConsole::default().error(markup!({ PrintDiagnostic(&diag) }));
+ EnvConsole::default().error(markup!({ PrintDiagnostic(&diag, true) }));
}
diff --git a/crates/rome_diagnostics/examples/lint.rs b/crates/rome_diagnostics/examples/lint.rs
index 01d12d36a4d9..e7390c6e16e2 100644
--- a/crates/rome_diagnostics/examples/lint.rs
+++ b/crates/rome_diagnostics/examples/lint.rs
@@ -90,5 +90,5 @@ console.log(FOO);";
},
};
- EnvConsole::default().error(markup!({ PrintDiagnostic(&diag) }));
+ EnvConsole::default().error(markup!({ PrintDiagnostic(&diag, true) }));
}
diff --git a/crates/rome_diagnostics/examples/serde.rs b/crates/rome_diagnostics/examples/serde.rs
index 428bc17226c8..6f5649ef1da9 100644
--- a/crates/rome_diagnostics/examples/serde.rs
+++ b/crates/rome_diagnostics/examples/serde.rs
@@ -53,6 +53,6 @@ fn from_str(input: &str) -> Result {
pub fn main() {
if let Err(err) = from_str("{\"syntax_error\"") {
- EnvConsole::default().error(markup!({ PrintDiagnostic(&err) }));
+ EnvConsole::default().error(markup!({ PrintDiagnostic(&err, true) }));
};
}
diff --git a/crates/rome_diagnostics/src/display.rs b/crates/rome_diagnostics/src/display.rs
index 2e26d9b8f539..a3a1cbb1f910 100644
--- a/crates/rome_diagnostics/src/display.rs
+++ b/crates/rome_diagnostics/src/display.rs
@@ -33,7 +33,7 @@ impl<'fmt, D: AsDiagnostic + ?Sized> std::fmt::Display for PrintDescription<'fmt
/// Helper struct for printing a diagnostic as markup into any formatter
/// implementing [rome_console::fmt::Write].
-pub struct PrintDiagnostic<'fmt, D: ?Sized>(pub &'fmt D);
+pub struct PrintDiagnostic<'fmt, D: ?Sized>(pub &'fmt D, pub bool);
impl<'fmt, D: AsDiagnostic + ?Sized> fmt::Display for PrintDiagnostic<'fmt, D> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> io::Result<()> {
@@ -49,7 +49,7 @@ impl<'fmt, D: AsDiagnostic + ?Sized> fmt::Display for PrintDiagnostic<'fmt, D> {
let mut fmt = IndentWriter::wrap(fmt, &mut slot, true, " ");
let mut visitor = PrintAdvices(&mut fmt);
- print_advices(&mut visitor, diagnostic, true)
+ print_advices(&mut visitor, diagnostic, self.1)
}
}
@@ -734,7 +734,7 @@ mod tests {
fn test_header() {
let diag = TestDiagnostic::::with_location();
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"path:1:1 internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -758,7 +758,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -788,7 +788,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -813,7 +813,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -838,7 +838,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -863,7 +863,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -889,7 +889,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
@@ -913,7 +913,7 @@ mod tests {
..TestDiagnostic::empty()
};
- let diag = markup!({ PrintDiagnostic(&diag) }).to_owned();
+ let diag = markup!({ PrintDiagnostic(&diag, true) }).to_owned();
let expected = markup!{
"internalError/io "" FIXABLE "" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
diff --git a/crates/rome_js_analyze/src/lib.rs b/crates/rome_js_analyze/src/lib.rs
index 8048d55d5a58..f7b79550816b 100644
--- a/crates/rome_js_analyze/src/lib.rs
+++ b/crates/rome_js_analyze/src/lib.rs
@@ -164,7 +164,7 @@ mod tests {
}
let error = diag.with_file_path("ahahah").with_file_source_code(SOURCE);
let text = markup_to_string(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
eprintln!("{text}");
}
diff --git a/crates/rome_js_analyze/tests/spec_tests.rs b/crates/rome_js_analyze/tests/spec_tests.rs
index 109ae280d3f8..2b41298c9fd5 100644
--- a/crates/rome_js_analyze/tests/spec_tests.rs
+++ b/crates/rome_js_analyze/tests/spec_tests.rs
@@ -171,7 +171,7 @@ fn diagnostic_to_string(name: &str, source: &str, diag: AnalyzerDiagnostic) -> S
.with_file_path((name, FileId::zero()))
.with_file_source_code(source);
let text = markup_to_string(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
text
diff --git a/crates/rome_js_formatter/src/check_reformat.rs b/crates/rome_js_formatter/src/check_reformat.rs
index 2533f0a82c36..501d59adc743 100644
--- a/crates/rome_js_formatter/src/check_reformat.rs
+++ b/crates/rome_js_formatter/src/check_reformat.rs
@@ -38,7 +38,7 @@ pub fn check_reformat(params: CheckReformatParams) {
.with_file_source_code(text.to_string());
Formatter::new(&mut Termcolor(&mut buffer))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.expect("failed to emit diagnostic");
}
diff --git a/crates/rome_js_formatter/tests/check_reformat.rs b/crates/rome_js_formatter/tests/check_reformat.rs
index 0098a080500b..fad302299bd3 100644
--- a/crates/rome_js_formatter/tests/check_reformat.rs
+++ b/crates/rome_js_formatter/tests/check_reformat.rs
@@ -39,7 +39,7 @@ pub fn check_reformat(params: CheckReformatParams) {
.with_file_source_code(text.to_string());
Formatter::new(&mut Termcolor(&mut buffer))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.expect("failed to emit diagnostic");
}
diff --git a/crates/rome_js_formatter/tests/prettier_tests.rs b/crates/rome_js_formatter/tests/prettier_tests.rs
index a4f2698bb7a8..a19c7a8b1fda 100644
--- a/crates/rome_js_formatter/tests/prettier_tests.rs
+++ b/crates/rome_js_formatter/tests/prettier_tests.rs
@@ -226,7 +226,7 @@ fn test_snapshot(input: &'static str, _: &str, _: &str, _: &str) {
.with_file_source_code(parse_input.clone());
Formatter::new(&mut Termcolor(&mut buffer))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.expect("failed to emit diagnostic");
}
diff --git a/crates/rome_js_parser/src/lib.rs b/crates/rome_js_parser/src/lib.rs
index 12e876563468..e3430b3d783e 100644
--- a/crates/rome_js_parser/src/lib.rs
+++ b/crates/rome_js_parser/src/lib.rs
@@ -517,7 +517,7 @@ impl ParseDiagnostic {
/// .with_file_source_code(source.to_string());
/// Formatter::new(&mut Termcolor(&mut write))
/// .write_markup(markup! {
- /// {PrintDiagnostic(&error)}
+ /// {PrintDiagnostic(&error, true)}
/// })
/// .expect("failed to emit diagnostic");
///
@@ -575,7 +575,7 @@ impl ParseDiagnostic {
/// .with_file_source_code(source.to_string());
/// Formatter::new(&mut Termcolor(&mut write))
/// .write_markup(markup! {
- /// {PrintDiagnostic(&error)}
+ /// {PrintDiagnostic(&error, true)}
/// })
/// .expect("failed to emit diagnostic");
///
diff --git a/crates/rome_js_parser/src/test_utils.rs b/crates/rome_js_parser/src/test_utils.rs
index 5cf3f2993f3f..88fc43ab3e7b 100644
--- a/crates/rome_js_parser/src/test_utils.rs
+++ b/crates/rome_js_parser/src/test_utils.rs
@@ -51,7 +51,7 @@ where
.with_file_source_code(syntax.to_string());
Formatter::new(&mut Termcolor(&mut buffer))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.unwrap();
}
diff --git a/crates/rome_js_parser/src/tests.rs b/crates/rome_js_parser/src/tests.rs
index 40c47f0ae18c..f8d008e56a04 100644
--- a/crates/rome_js_parser/src/tests.rs
+++ b/crates/rome_js_parser/src/tests.rs
@@ -125,7 +125,7 @@ fn run_and_expect_errors(path: &str, _: &str, _: &str, _: &str) {
.with_file_source_code(text.to_string());
Formatter::new(&mut Termcolor(&mut write))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.expect("failed to emit diagnostic");
write!(
@@ -378,7 +378,7 @@ fn diagnostics_print_correctly() {
Formatter::new(&mut Termcolor(&mut write))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.expect("failed to emit diagnostic");
diff --git a/crates/rome_js_semantic/src/tests/assertions.rs b/crates/rome_js_semantic/src/tests/assertions.rs
index 4f3566f7bcb4..0b09814721a2 100644
--- a/crates/rome_js_semantic/src/tests/assertions.rs
+++ b/crates/rome_js_semantic/src/tests/assertions.rs
@@ -114,7 +114,7 @@ pub fn assert(code: &str, test_name: &str) {
.with_file_path(FileId::zero())
.with_file_source_code(code);
console.log(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
}
panic!("Compilation error");
@@ -758,7 +758,7 @@ fn error_assertion_not_attached_to_a_declaration(
let mut console = EnvConsole::default();
console.log(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
panic!("This assertion must be attached to a SemanticEvent::DeclarationFound.");
}
@@ -779,7 +779,7 @@ fn error_declaration_pointing_to_unknown_scope(
let mut console = EnvConsole::default();
console.log(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
}
@@ -804,7 +804,7 @@ fn error_assertion_name_clash(
let mut console = EnvConsole::default();
console.log(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
panic!("Assertion label conflict");
@@ -827,7 +827,7 @@ fn error_scope_end_assertion_points_to_non_existing_scope_start_assertion(
let mut console = EnvConsole::default();
console.log(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
panic!("Scope start assertion not found.");
}
@@ -854,7 +854,7 @@ fn error_scope_end_assertion_points_to_the_wrong_scope_start(
let mut console = EnvConsole::default();
console.log(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
});
panic!("Wrong scope start");
}
diff --git a/crates/rome_wasm/src/utils.rs b/crates/rome_wasm/src/utils.rs
index 99aaabd2d6d7..20b9dd9e1836 100644
--- a/crates/rome_wasm/src/utils.rs
+++ b/crates/rome_wasm/src/utils.rs
@@ -43,7 +43,7 @@ impl DiagnosticPrinter {
}
}
- pub fn print(&mut self, diagnostic: IDiagnostic) -> Result<(), Error> {
+ pub fn print(&mut self, diagnostic: IDiagnostic, verbose: bool) -> Result<(), Error> {
let diag: Diagnostic = diagnostic.into_serde().map_err(into_error)?;
let err = diag
.with_file_path(&self.file_name)
@@ -51,7 +51,7 @@ impl DiagnosticPrinter {
let mut html = HTML(&mut self.buffer);
Formatter::new(&mut html)
- .write_markup(markup!({ PrintDiagnostic(&err) }))
+ .write_markup(markup!({ PrintDiagnostic(&err, verbose) }))
.map_err(into_error)?;
Ok(())
diff --git a/xtask/bench/src/features/parser.rs b/xtask/bench/src/features/parser.rs
index aefc4d6c3545..91f6cfd22ffd 100644
--- a/xtask/bench/src/features/parser.rs
+++ b/xtask/bench/src/features/parser.rs
@@ -106,7 +106,7 @@ impl Display for ParseMeasurement {
.with_file_source_code(self.code.clone());
rome_diagnostics::console::fmt::Formatter::new(&mut Termcolor(&mut buffer))
.write_markup(markup! {
- {PrintDiagnostic(&error)}
+ {PrintDiagnostic(&error, true)}
})
.unwrap();
}
diff --git a/xtask/coverage/src/runner.rs b/xtask/coverage/src/runner.rs
index 019db627b1a6..a29fe109fe0e 100644
--- a/xtask/coverage/src/runner.rs
+++ b/xtask/coverage/src/runner.rs
@@ -150,7 +150,7 @@ impl TestCaseFiles {
pub(crate) fn emit_errors(&self, errors: &[Error], buffer: &mut Buffer) {
for error in errors {
if let Err(err) = Formatter::new(&mut Termcolor(&mut *buffer)).write_markup(markup! {
- {PrintDiagnostic(error)}
+ {PrintDiagnostic(error, true)}
}) {
eprintln!("Failed to print diagnostic: {}", err);
}
diff --git a/xtask/lintdoc/src/main.rs b/xtask/lintdoc/src/main.rs
index ad2e1c607f87..51a9f993e77c 100644
--- a/xtask/lintdoc/src/main.rs
+++ b/xtask/lintdoc/src/main.rs
@@ -466,7 +466,7 @@ fn assert_lint(
let mut write_diagnostic = |code: &str, diag: rome_diagnostics::Error| {
let category = diag.category().map_or("", |code| code.name());
Formatter::new(&mut write).write_markup(markup! {
- {PrintDiagnostic(&diag)}
+ {PrintDiagnostic(&diag, true)}
})?;
all_diagnostics.push(diag);
@@ -479,7 +479,7 @@ fn assert_lint(
console.print(
rome_console::LogLevel::Error,
markup! {
- {PrintDiagnostic(diag)}
+ {PrintDiagnostic(diag, true)}
},
);
}
@@ -497,7 +497,7 @@ fn assert_lint(
console.print(
rome_console::LogLevel::Error,
markup! {
- {PrintDiagnostic(diag)}
+ {PrintDiagnostic(diag, true)}
},
);
}