From 63392b35a1dad0daddf9fa174d72036ede2496b6 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 25 Oct 2024 21:12:56 -0600 Subject: [PATCH] It works! --- crates/biome_cli/src/execute/process_file.rs | 3 ++- .../biome_cli/src/execute/process_file/check.rs | 2 +- .../biome_cli/src/execute/process_file/lint.rs | 17 +++++++++++++++-- .../src/suppression_action.rs | 4 ++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/biome_cli/src/execute/process_file.rs b/crates/biome_cli/src/execute/process_file.rs index 955b16b132df..2beb3962fc72 100644 --- a/crates/biome_cli/src/execute/process_file.rs +++ b/crates/biome_cli/src/execute/process_file.rs @@ -211,10 +211,11 @@ pub(crate) fn process_file(ctx: &TraversalOptions, biome_path: &BiomePath) -> Fi match ctx.execution.traversal_mode { TraversalMode::Lint { ref suppression_reason, + suppress, .. } => { // the unsupported case should be handled already at this point - lint(shared_context, biome_path, suppression_reason) + lint(shared_context, biome_path, suppress, suppression_reason) } TraversalMode::Format { .. } => { // the unsupported case should be handled already at this point diff --git a/crates/biome_cli/src/execute/process_file/check.rs b/crates/biome_cli/src/execute/process_file/check.rs index d0287164e5dc..2981c79ee05a 100644 --- a/crates/biome_cli/src/execute/process_file/check.rs +++ b/crates/biome_cli/src/execute/process_file/check.rs @@ -18,7 +18,7 @@ pub(crate) fn check_file<'ctx>( tracing::info_span!("Process check", path =? workspace_file.path.display()).in_scope( move || { if file_features.supports_lint() { - let lint_result = lint_with_guard(ctx, &mut workspace_file, None); + let lint_result = lint_with_guard(ctx, &mut workspace_file, false, None); match lint_result { Ok(status) => { if status.is_changed() { diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index 2169a0a155ff..0be11873b84f 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -14,15 +14,22 @@ use std::sync::atomic::Ordering; pub(crate) fn lint<'ctx>( ctx: &'ctx SharedTraversalOptions<'ctx, '_>, path: &Path, + suppress: bool, suppression_reason: &Option, ) -> FileResult { let mut workspace_file = WorkspaceFile::new(ctx, path)?; - lint_with_guard(ctx, &mut workspace_file, suppression_reason.clone()) + lint_with_guard( + ctx, + &mut workspace_file, + suppress, + suppression_reason.clone(), + ) } pub(crate) fn lint_with_guard<'ctx>( ctx: &'ctx SharedTraversalOptions<'ctx, '_>, workspace_file: &mut WorkspaceFile, + suppress: bool, suppression_reason: Option, ) -> FileResult { tracing::info_span!("Processes linting", path =? workspace_file.path.display()).in_scope( @@ -36,6 +43,12 @@ pub(crate) fn lint_with_guard<'ctx>( (Vec::new(), Vec::new()) }; if let Some(fix_mode) = ctx.execution.as_fix_file_mode() { + let suppression_explanation = if suppress && suppression_reason.is_none() { + "Ignored using `--suppress`".to_string() + } else { + suppression_reason.unwrap_or("".to_string()) + }; + let fix_result = workspace_file .guard() .fix_file( @@ -47,7 +60,7 @@ pub(crate) fn lint_with_guard<'ctx>( .build(), only.clone(), skip.clone(), - Some(suppression_reason.unwrap_or("".to_string())), + Some(suppression_explanation), ) .with_file_path_and_code( workspace_file.path.display().to_string(), diff --git a/crates/biome_graphql_analyze/src/suppression_action.rs b/crates/biome_graphql_analyze/src/suppression_action.rs index e5bd5e22f2f4..08f997e6f5a2 100644 --- a/crates/biome_graphql_analyze/src/suppression_action.rs +++ b/crates/biome_graphql_analyze/src/suppression_action.rs @@ -39,7 +39,7 @@ impl SuppressionAction for GraphqlSuppressionAction { mutation: &mut BatchMutation, apply_suppression: ApplySuppression, suppression_text: &str, - _suppression_reason: String, + suppression_reason: String, ) { let ApplySuppression { token_to_apply_suppression, @@ -53,7 +53,7 @@ impl SuppressionAction for GraphqlSuppressionAction { .filter(|trivia| trivia.is_whitespace()) .collect(); - let suppression_comment = format!("# {}: ", suppression_text); + let suppression_comment = format!("# {}: {}", suppression_text, suppression_reason); let suppression_comment = suppression_comment.as_str(); let trivia = [ (TriviaPieceKind::SingleLineComment, suppression_comment),