Add color to fixable error asterisk (#2647)

This commit is contained in:
Charlie Marsh 2023-02-07 19:12:18 -05:00 committed by GitHub
parent 56398e0002
commit 367f115d83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,7 +122,8 @@ impl<'a> Printer<'a> {
if num_fixable > 0 { if num_fixable > 0 {
writeln!( writeln!(
stdout, stdout,
"[*] {num_fixable} potentially fixable with the --fix option." "[{}] {num_fixable} potentially fixable with the --fix option.",
"*".cyan(),
)?; )?;
} }
} }
@ -477,7 +478,7 @@ fn num_digits(n: usize) -> usize {
fn print_message<T: Write>(stdout: &mut T, message: &Message) -> Result<()> { fn print_message<T: Write>(stdout: &mut T, message: &Message) -> Result<()> {
let label = if message.kind.fixable() { let label = if message.kind.fixable() {
format!( format!(
"{}{}{}{}{}{} {} [*] {}", "{}{}{}{}{}{} {} [{}] {}",
relativize_path(Path::new(&message.filename)).bold(), relativize_path(Path::new(&message.filename)).bold(),
":".cyan(), ":".cyan(),
message.location.row(), message.location.row(),
@ -485,6 +486,7 @@ fn print_message<T: Write>(stdout: &mut T, message: &Message) -> Result<()> {
message.location.column(), message.location.column(),
":".cyan(), ":".cyan(),
message.kind.rule().code().red().bold(), message.kind.rule().code().red().bold(),
"*".cyan(),
message.kind.body(), message.kind.body(),
) )
} else { } else {
@ -556,13 +558,14 @@ fn print_grouped_message<T: Write>(
) -> Result<()> { ) -> Result<()> {
let label = if message.kind.fixable() { let label = if message.kind.fixable() {
format!( format!(
" {}{}{}{}{} {} [*] {}", " {}{}{}{}{} {} [{}] {}",
" ".repeat(row_length - num_digits(message.location.row())), " ".repeat(row_length - num_digits(message.location.row())),
message.location.row(), message.location.row(),
":".cyan(), ":".cyan(),
message.location.column(), message.location.column(),
" ".repeat(column_length - num_digits(message.location.column())), " ".repeat(column_length - num_digits(message.location.column())),
message.kind.rule().code().red().bold(), message.kind.rule().code().red().bold(),
"*".cyan(),
message.kind.body(), message.kind.body(),
) )
} else { } else {