From 62e46bcdc3bbf008736a49009efb9229a7428a66 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Sep 2024 21:24:49 -0600 Subject: [PATCH 01/88] WIP --- crates/biome_cli/src/commands/lint.rs | 3 +++ crates/biome_cli/src/commands/mod.rs | 5 +++++ crates/biome_cli/src/execute/mod.rs | 14 ++++++++++++++ crates/biome_cli/src/execute/process_file.rs | 1 + crates/biome_cli/src/execute/process_file/lint.rs | 4 ++++ crates/biome_cli/src/execute/std_in.rs | 4 ++++ crates/biome_cli/src/lib.rs | 2 ++ 7 files changed, 33 insertions(+) diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index 84ab59f0f440..96ca0f79c2b1 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -45,6 +45,7 @@ pub(crate) struct LintCommandPayload { pub(crate) json_linter: Option, pub(crate) css_linter: Option, pub(crate) graphql_linter: Option, + pub(crate) write_suppressions: Option, } /// Handler for the "lint" command of the Biome CLI @@ -70,6 +71,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( css_linter, json_linter, graphql_linter, + write_suppressions, } = payload; setup_cli_subscriber(cli_options.log_level, cli_options.log_kind); @@ -181,6 +183,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( only, skip, vcs_targeted: VcsTargeted { staged, changed }, + write_suppressions, }) .set_report(&cli_options), session, diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 5e68992a2456..ed91ace9d74b 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -220,6 +220,11 @@ pub enum BiomeCommand { #[bpaf(external(partial_graphql_linter), optional, hide_usage, hide)] graphql_linter: Option, + // TODO: The flag requires a value here. Am I able to let them pass `--write-suppressions`, + // without a value? Option> wasn't it. + #[bpaf(long("write-suppressions"))] + write_suppressions: Option, + #[bpaf(external, hide_usage)] cli_options: CliOptions, diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index 61b22930d1ed..59a6a47f1f57 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -151,6 +151,7 @@ pub enum TraversalMode { skip: Vec, /// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled vcs_targeted: VcsTargeted, + write_suppressions: Option, }, /// This mode is enabled when running the command `biome ci` CI { @@ -304,6 +305,19 @@ impl Execution { } } + pub(crate) fn as_write_suppressions_mode(&self) -> Option { + match &self.traversal_mode { + TraversalMode::Lint { + write_suppressions, .. + } => Some(write_suppressions.as_ref().is_some()), + TraversalMode::Check { .. } + | TraversalMode::Format { .. } + | TraversalMode::CI { .. } + | TraversalMode::Migrate { .. } + | TraversalMode::Search { .. } => None, + } + } + pub(crate) fn as_diagnostic_category(&self) -> &'static Category { match self.traversal_mode { TraversalMode::Check { .. } => category!("check"), diff --git a/crates/biome_cli/src/execute/process_file.rs b/crates/biome_cli/src/execute/process_file.rs index 79ea7dc3d871..9a0daa852e1f 100644 --- a/crates/biome_cli/src/execute/process_file.rs +++ b/crates/biome_cli/src/execute/process_file.rs @@ -128,6 +128,7 @@ impl<'ctx, 'app> Deref for SharedTraversalOptions<'ctx, 'app> { /// content of the file and emit a diff or write the new content to the disk if /// write mode is enabled pub(crate) fn process_file(ctx: &TraversalOptions, biome_path: &BiomePath) -> FileResult { + ctx.execution.as_write_suppressions_mode(); tracing::trace_span!("process_file", path = ?biome_path).in_scope(move || { let file_features = ctx .workspace diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index b5e4a7db823c..7f252fccdc05 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -73,6 +73,10 @@ pub(crate) fn lint_with_guard<'ctx>( } } + // if let Some(write_suppressions_mode) = ctx.as_write_suppressions_mode() { + // println!("write_suppressions_mode: {write_suppressions_mode}"); + // } + let max_diagnostics = ctx.remaining_diagnostics.load(Ordering::Relaxed); let pull_diagnostics_result = workspace_file .guard() diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index cf793abea81d..3d7d4a2653be 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -144,6 +144,10 @@ pub(crate) fn run<'a>( } } + if let Some(write_suppressions_mode) = mode.as_write_suppressions_mode() { + println!("write_suppressions_mode: {write_suppressions_mode}"); + } + if file_features.supports_organize_imports() && mode.is_check() { let result = workspace.organize_imports(OrganizeImportsParams { path: biome_path.clone(), diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 653ebdc1d32f..365d4d5be4f8 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -145,6 +145,7 @@ impl<'app> CliSession<'app> { javascript_linter, json_linter, graphql_linter, + write_suppressions, } => commands::lint::lint( self, LintCommandPayload { @@ -168,6 +169,7 @@ impl<'app> CliSession<'app> { javascript_linter, json_linter, graphql_linter, + write_suppressions, }, ), BiomeCommand::Ci { From 9c50af17472e6a63ebe0a0ffa07e2aeae95eb711 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Sep 2024 22:31:41 -0600 Subject: [PATCH 02/88] WIP --- .../src/execute/process_file/lint.rs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index 7f252fccdc05..e3542f985c58 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -2,7 +2,7 @@ use crate::execute::diagnostics::ResultExt; use crate::execute::process_file::workspace_file::WorkspaceFile; use crate::execute::process_file::{FileResult, FileStatus, Message, SharedTraversalOptions}; use crate::TraversalMode; -use biome_analyze::RuleCategoriesBuilder; +use biome_analyze::{Rule, RuleCategoriesBuilder}; use biome_diagnostics::{category, Error}; use biome_rowan::TextSize; use biome_service::file_handlers::{AstroFileHandler, SvelteFileHandler, VueFileHandler}; @@ -73,10 +73,6 @@ pub(crate) fn lint_with_guard<'ctx>( } } - // if let Some(write_suppressions_mode) = ctx.as_write_suppressions_mode() { - // println!("write_suppressions_mode: {write_suppressions_mode}"); - // } - let max_diagnostics = ctx.remaining_diagnostics.load(Ordering::Relaxed); let pull_diagnostics_result = workspace_file .guard() @@ -98,30 +94,34 @@ pub(crate) fn lint_with_guard<'ctx>( && pull_diagnostics_result.skipped_diagnostics == 0; if !no_diagnostics { - let offset = match workspace_file.as_extension().map(OsStr::as_encoded_bytes) { - Some(b"vue") => VueFileHandler::start(input.as_str()), - Some(b"astro") => AstroFileHandler::start(input.as_str()), - Some(b"svelte") => SvelteFileHandler::start(input.as_str()), - _ => None, - }; + if let Some(write_suppressions_mode) = ctx.execution.as_write_suppressions_mode() { + println!("Rule::suppress() here"); + } else { + let offset = match workspace_file.as_extension().map(OsStr::as_encoded_bytes) { + Some(b"vue") => VueFileHandler::start(input.as_str()), + Some(b"astro") => AstroFileHandler::start(input.as_str()), + Some(b"svelte") => SvelteFileHandler::start(input.as_str()), + _ => None, + }; - ctx.push_message(Message::Diagnostics { - name: workspace_file.path.display().to_string(), - content: input, - diagnostics: pull_diagnostics_result - .diagnostics - .into_iter() - .map(|d| { - if let Some(offset) = offset { - d.with_offset(TextSize::from(offset)) - } else { - d - } - }) - .map(Error::from) - .collect(), - skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics as u32, - }); + ctx.push_message(Message::Diagnostics { + name: workspace_file.path.display().to_string(), + content: input, + diagnostics: pull_diagnostics_result + .diagnostics + .into_iter() + .map(|d| { + if let Some(offset) = offset { + d.with_offset(TextSize::from(offset)) + } else { + d + } + }) + .map(Error::from) + .collect(), + skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics as u32, + }); + } } if changed { From a87006b95e3902207c2eb3e60ce4b57ec284b476 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Sep 2024 22:55:09 -0600 Subject: [PATCH 03/88] WIP --- crates/biome_cli/src/execute/process_file/lint.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index e3542f985c58..dfd858bddd5e 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -95,6 +95,7 @@ pub(crate) fn lint_with_guard<'ctx>( if !no_diagnostics { if let Some(write_suppressions_mode) = ctx.execution.as_write_suppressions_mode() { + // Rule::suppress() println!("Rule::suppress() here"); } else { let offset = match workspace_file.as_extension().map(OsStr::as_encoded_bytes) { From a39718d90440c4bf945df015d3275f4ad62c1856 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 19 Sep 2024 23:00:57 -0600 Subject: [PATCH 04/88] WIP --- crates/biome_cli/src/execute/std_in.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index 3d7d4a2653be..cf793abea81d 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -144,10 +144,6 @@ pub(crate) fn run<'a>( } } - if let Some(write_suppressions_mode) = mode.as_write_suppressions_mode() { - println!("write_suppressions_mode: {write_suppressions_mode}"); - } - if file_features.supports_organize_imports() && mode.is_check() { let result = workspace.organize_imports(OrganizeImportsParams { path: biome_path.clone(), From cf0b9c07a37c7f4ba34d7e51146fd79f1f68c634 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sun, 22 Sep 2024 15:18:11 -0600 Subject: [PATCH 05/88] WIP --- crates/biome_cli/src/commands/check.rs | 1 + crates/biome_cli/src/commands/mod.rs | 24 ++++++++- .../src/execute/process_file/lint.rs | 51 +++++++++---------- crates/biome_service/src/file_handlers/css.rs | 3 ++ .../src/file_handlers/graphql.rs | 3 ++ .../src/file_handlers/javascript.rs | 4 ++ .../biome_service/src/file_handlers/json.rs | 3 ++ crates/biome_service/src/workspace.rs | 1 + 8 files changed, 60 insertions(+), 30 deletions(-) diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index d0584dd2e26f..30145a86ecef 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -73,6 +73,7 @@ pub(crate) fn check( apply, apply_unsafe, write, + write_suppressions, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index ed91ace9d74b..455c191ae28a 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -729,6 +729,7 @@ pub(crate) struct FixFileModeOptions { apply: bool, apply_unsafe: bool, write: bool, + write_suppressions: bool, fix: bool, unsafe_: bool, } @@ -745,6 +746,7 @@ pub(crate) fn determine_fix_file_mode( apply_unsafe, write, fix, + write_suppressions, unsafe_, } = options; @@ -769,6 +771,8 @@ pub(crate) fn determine_fix_file_mode( Ok(Some(FixFileMode::SafeAndUnsafeFixes)) } else if safe_fixes { Ok(Some(FixFileMode::SafeFixes)) + } else if write_suppressions { + Ok(Some(FixFileMode::ApplySuppressions)) } else { Ok(None) } @@ -780,6 +784,7 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C apply, apply_unsafe, write, + write_suppressions, fix, unsafe_, } = options; @@ -805,6 +810,16 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C )); } else if write && fix { return Err(CliDiagnostic::incompatible_arguments("--write", "--fix")); + } else if write_suppressions && write { + return Err(CliDiagnostic::incompatible_arguments( + "--write-suppressions", + "--write", + )); + } else if write_suppressions && fix { + return Err(CliDiagnostic::incompatible_arguments( + "--write-suppressions", + "--fix", + )); } Ok(()) } @@ -830,6 +845,7 @@ mod tests { apply, apply_unsafe, write, + write_suppressions, fix, unsafe_ }) @@ -852,6 +868,7 @@ mod tests { apply, apply_unsafe, write, + write_suppressions, fix, unsafe_ }, @@ -867,7 +884,7 @@ mod tests { fn safe_and_unsafe_fixes() { let mut console = BufferConsole::default(); - for (apply, apply_unsafe, write, fix, unsafe_) in [ + for (apply, apply_unsafe, write, fix, write_suppressions, unsafe_) in [ (false, true, false, false, false), // --apply-unsafe (false, false, true, false, true), // --write --unsafe (false, false, false, true, true), // --fix --unsafe @@ -878,6 +895,7 @@ mod tests { apply, apply_unsafe, write, + write_suppressions, fix, unsafe_ }, @@ -893,13 +911,15 @@ mod tests { fn no_fix() { let mut console = BufferConsole::default(); - let (apply, apply_unsafe, write, fix, unsafe_) = (false, false, false, false, false); + let (apply, apply_unsafe, write, fix, write_suppressions, unsafe_) = + (false, false, false, false, false, false); assert_eq!( determine_fix_file_mode( FixFileModeOptions { apply, apply_unsafe, write, + write_suppressions, fix, unsafe_ }, diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index dfd858bddd5e..a36510b41c06 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -94,35 +94,30 @@ pub(crate) fn lint_with_guard<'ctx>( && pull_diagnostics_result.skipped_diagnostics == 0; if !no_diagnostics { - if let Some(write_suppressions_mode) = ctx.execution.as_write_suppressions_mode() { - // Rule::suppress() - println!("Rule::suppress() here"); - } else { - let offset = match workspace_file.as_extension().map(OsStr::as_encoded_bytes) { - Some(b"vue") => VueFileHandler::start(input.as_str()), - Some(b"astro") => AstroFileHandler::start(input.as_str()), - Some(b"svelte") => SvelteFileHandler::start(input.as_str()), - _ => None, - }; + let offset = match workspace_file.as_extension().map(OsStr::as_encoded_bytes) { + Some(b"vue") => VueFileHandler::start(input.as_str()), + Some(b"astro") => AstroFileHandler::start(input.as_str()), + Some(b"svelte") => SvelteFileHandler::start(input.as_str()), + _ => None, + }; - ctx.push_message(Message::Diagnostics { - name: workspace_file.path.display().to_string(), - content: input, - diagnostics: pull_diagnostics_result - .diagnostics - .into_iter() - .map(|d| { - if let Some(offset) = offset { - d.with_offset(TextSize::from(offset)) - } else { - d - } - }) - .map(Error::from) - .collect(), - skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics as u32, - }); - } + ctx.push_message(Message::Diagnostics { + name: workspace_file.path.display().to_string(), + content: input, + diagnostics: pull_diagnostics_result + .diagnostics + .into_iter() + .map(|d| { + if let Some(offset) = offset { + d.with_offset(TextSize::from(offset)) + } else { + d + } + }) + .map(Error::from) + .collect(), + skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics as u32, + }); } if changed { diff --git a/crates/biome_service/src/file_handlers/css.rs b/crates/biome_service/src/file_handlers/css.rs index 54ebae9dc92b..12137c7c95c3 100644 --- a/crates/biome_service/src/file_handlers/css.rs +++ b/crates/biome_service/src/file_handlers/css.rs @@ -563,6 +563,9 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { + println!("No-op'ing in CSS.") + } } } diff --git a/crates/biome_service/src/file_handlers/graphql.rs b/crates/biome_service/src/file_handlers/graphql.rs index 255b2cfcd12c..f5331a2d8f56 100644 --- a/crates/biome_service/src/file_handlers/graphql.rs +++ b/crates/biome_service/src/file_handlers/graphql.rs @@ -529,6 +529,9 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { + println!("No-op'ing in JSON.") + } } } diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index b5d694b3194c..1b623ca73bec 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -659,6 +659,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result Result { + println!("Made it to da block.") + } } } diff --git a/crates/biome_service/src/file_handlers/json.rs b/crates/biome_service/src/file_handlers/json.rs index 6d98907cdb22..4c1680c96653 100644 --- a/crates/biome_service/src/file_handlers/json.rs +++ b/crates/biome_service/src/file_handlers/json.rs @@ -584,6 +584,9 @@ fn fix_all(params: FixAllParams) -> Result { return ControlFlow::Break(action); } } + FixFileMode::ApplySuppressions => { + println!("No-op'ing in JSON.") + } } } diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index 2b6fcdc45036..047ec7644d35 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -627,6 +627,7 @@ pub enum FixFileMode { SafeFixes, /// Applies [safe](biome_diagnostics::Applicability::Always) and [unsafe](biome_diagnostics::Applicability::MaybeIncorrect) fixes SafeAndUnsafeFixes, + ApplySuppressions, } #[derive(Debug, serde::Serialize, serde::Deserialize)] From 02115cc7404f72bd5421e21d028c57de921c49b4 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sun, 22 Sep 2024 23:02:06 -0600 Subject: [PATCH 06/88] WIP --- crates/biome_cli/src/commands/check.rs | 2 ++ crates/biome_cli/src/commands/format.rs | 3 +++ crates/biome_cli/src/commands/lint.rs | 3 ++- crates/biome_cli/src/commands/migrate.rs | 2 ++ crates/biome_cli/src/commands/mod.rs | 18 ++++++++++++------ crates/biome_cli/src/execute/mod.rs | 6 +++--- .../biome_cli/src/execute/process_file/lint.rs | 2 +- crates/biome_cli/src/lib.rs | 14 +++++++++++++- 8 files changed, 38 insertions(+), 12 deletions(-) diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index 30145a86ecef..6c8b37aa9866 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -28,6 +28,7 @@ pub(crate) struct CheckCommandPayload { pub(crate) apply: bool, pub(crate) apply_unsafe: bool, pub(crate) write: bool, + pub(crate) write_suppressions: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -52,6 +53,7 @@ pub(crate) fn check( apply, apply_unsafe, write, + write_suppressions, fix, unsafe_, cli_options, diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 0438e60f5706..bb3960fdc0e8 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -33,6 +33,7 @@ pub(crate) struct FormatCommandPayload { pub(crate) files_configuration: Option, pub(crate) stdin_file_path: Option, pub(crate) write: bool, + pub(crate) write_suppressions: bool, pub(crate) fix: bool, pub(crate) cli_options: CliOptions, pub(crate) paths: Vec, @@ -55,6 +56,7 @@ pub(crate) fn format( stdin_file_path, files_configuration, write, + write_suppressions, fix, mut json_formatter, css_formatter, @@ -69,6 +71,7 @@ pub(crate) fn format( apply: false, apply_unsafe: false, write, + write_suppressions, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index 96ca0f79c2b1..871209f57027 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -28,6 +28,7 @@ pub(crate) struct LintCommandPayload { pub(crate) apply: bool, pub(crate) apply_unsafe: bool, pub(crate) write: bool, + pub(crate) write_suppressions: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -45,7 +46,6 @@ pub(crate) struct LintCommandPayload { pub(crate) json_linter: Option, pub(crate) css_linter: Option, pub(crate) graphql_linter: Option, - pub(crate) write_suppressions: Option, } /// Handler for the "lint" command of the Biome CLI @@ -80,6 +80,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply, apply_unsafe, write, + write_suppressions, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index 7f0362f3ab90..6211532817bc 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -13,6 +13,7 @@ pub(crate) fn migrate( session: CliSession, cli_options: CliOptions, write: bool, + write_suppressions: bool, fix: bool, sub_command: Option, ) -> Result<(), CliDiagnostic> { @@ -29,6 +30,7 @@ pub(crate) fn migrate( apply: false, apply_unsafe: false, write, + write_suppressions, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 455c191ae28a..977f7eee8efc 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -105,6 +105,10 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, + /// Writes inline biome-ignore comments to ignore existing diagnostics + #[bpaf(long("write"), switch)] + write_suppressions: bool, + /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] unsafe_: bool, @@ -220,10 +224,8 @@ pub enum BiomeCommand { #[bpaf(external(partial_graphql_linter), optional, hide_usage, hide)] graphql_linter: Option, - // TODO: The flag requires a value here. Am I able to let them pass `--write-suppressions`, - // without a value? Option> wasn't it. #[bpaf(long("write-suppressions"))] - write_suppressions: Option, + write_suppressions: bool, #[bpaf(external, hide_usage)] cli_options: CliOptions, @@ -303,6 +305,7 @@ pub enum BiomeCommand { /// Writes formatted files to file system. #[bpaf(long("write"), switch)] write: bool, + write_suppressions: bool, /// Alias of `--write`, writes formatted files to file system. #[bpaf(long("fix"), switch, hide_usage)] @@ -413,6 +416,10 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, + /// Writes inline biome-ignore comments to ignore existing diagnostics + #[bpaf(long("write"), switch)] + write_suppressions: bool, + /// Alias of `--write`, writes the new configuration file to disk #[bpaf(long("fix"), switch, hide_usage)] fix: bool, @@ -884,7 +891,7 @@ mod tests { fn safe_and_unsafe_fixes() { let mut console = BufferConsole::default(); - for (apply, apply_unsafe, write, fix, write_suppressions, unsafe_) in [ + for (apply, apply_unsafe, write, fix, unsafe_) in [ (false, true, false, false, false), // --apply-unsafe (false, false, true, false, true), // --write --unsafe (false, false, false, true, true), // --fix --unsafe @@ -911,8 +918,7 @@ mod tests { fn no_fix() { let mut console = BufferConsole::default(); - let (apply, apply_unsafe, write, fix, write_suppressions, unsafe_) = - (false, false, false, false, false, false); + let (apply, apply_unsafe, write, fix, unsafe_) = (false, false, false, false, false); assert_eq!( determine_fix_file_mode( FixFileModeOptions { diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index 59a6a47f1f57..54f19ff1fc13 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -151,7 +151,7 @@ pub enum TraversalMode { skip: Vec, /// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled vcs_targeted: VcsTargeted, - write_suppressions: Option, + write_suppressions: bool, }, /// This mode is enabled when running the command `biome ci` CI { @@ -305,11 +305,11 @@ impl Execution { } } - pub(crate) fn as_write_suppressions_mode(&self) -> Option { + pub(crate) fn as_write_suppressions_mode(&self) -> Option<&bool> { match &self.traversal_mode { TraversalMode::Lint { write_suppressions, .. - } => Some(write_suppressions.as_ref().is_some()), + } => Some(write_suppressions), TraversalMode::Check { .. } | TraversalMode::Format { .. } | TraversalMode::CI { .. } diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index a36510b41c06..b5e4a7db823c 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -2,7 +2,7 @@ use crate::execute::diagnostics::ResultExt; use crate::execute::process_file::workspace_file::WorkspaceFile; use crate::execute::process_file::{FileResult, FileStatus, Message, SharedTraversalOptions}; use crate::TraversalMode; -use biome_analyze::{Rule, RuleCategoriesBuilder}; +use biome_analyze::RuleCategoriesBuilder; use biome_diagnostics::{category, Error}; use biome_rowan::TextSize; use biome_service::file_handlers::{AstroFileHandler, SvelteFileHandler, VueFileHandler}; diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 365d4d5be4f8..19c03ff19246 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -90,6 +90,7 @@ impl<'app> CliSession<'app> { apply, apply_unsafe, write, + write_suppressions, fix, unsafe_, cli_options, @@ -109,6 +110,7 @@ impl<'app> CliSession<'app> { apply_unsafe, apply, write, + write_suppressions, fix, unsafe_, cli_options, @@ -201,6 +203,7 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, + write_suppressions, fix, cli_options, paths, @@ -219,6 +222,7 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, + write_suppressions, fix, cli_options, paths, @@ -243,9 +247,17 @@ impl<'app> CliSession<'app> { BiomeCommand::Migrate { cli_options, write, + write_suppressions, + fix, + sub_command, + } => commands::migrate::migrate( + self, + cli_options, + write, + write_suppressions, fix, sub_command, - } => commands::migrate::migrate(self, cli_options, write, fix, sub_command), + ), BiomeCommand::Search { cli_options, files_configuration, From 3b613f0febd6742c9af769ce099fef8c4a9d7269 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 23 Sep 2024 13:42:32 -0600 Subject: [PATCH 07/88] WIP --- crates/biome_service/src/file_handlers/javascript.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 1b623ca73bec..02c982a38906 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -21,7 +21,7 @@ use crate::{ }; use biome_analyze::options::PreferredQuote; use biome_analyze::{ - AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, QueryMatch, + AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, QueryMatch, Rule, RuleCategoriesBuilder, RuleCategory, RuleError, RuleFilter, }; use biome_configuration::javascript::JsxRuntime; @@ -659,8 +659,6 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result Result { - println!("Made it to da block.") + // TODO: Now what goes in these parentheses...? + Rule::suppress(); } } } From 2eb7cdc81f29dbcb9133f0b0340b45e4de90c309 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 23 Sep 2024 13:44:36 -0600 Subject: [PATCH 08/88] WIP --- crates/biome_service/src/file_handlers/javascript.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 02c982a38906..41d9d9a1ae67 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -683,7 +683,8 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { - // TODO: Now what goes in these parentheses...? + // TODO: Now where do I get ctx, text_range, and suppression_action + // from...? Rule::suppress(); } } From c378a77865716fd82d3ad1e82ea80e2bcf2bbabf Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 26 Sep 2024 00:21:20 -0600 Subject: [PATCH 09/88] WIP --- .../tests/specs/prettier/.DS_Store | Bin 0 -> 6148 bytes .../src/file_handlers/javascript.rs | 17 ++++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 crates/biome_js_formatter/tests/specs/prettier/.DS_Store diff --git a/crates/biome_js_formatter/tests/specs/prettier/.DS_Store b/crates/biome_js_formatter/tests/specs/prettier/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0dbb24996c15ca38935eafe3055982373c73df72 GIT binary patch literal 6148 zcmeHKJ5Iwu5SRfl=yQQ62?C;6wn&hmTLcX!py4XC+=mp0%Q5fFO`b0ed7 zn*lz%4$Wz~xbBaBoS)c>GS4TAa)P*I@bPf+a{f73=M?3v)mPor)_WQwg^p-Nk5thW zEon-3bc^|_v2XJB)fQK;<2k&p>)5$wy{_M48+Bevom{JnGvEw31N+PXdNxaPtmvaN z;0!ne8wU9MkU|+V!>A~q4h(Vy0Cr&(!JO|BoRb=6hEWk7NYGTErUtuW1WkuMwYbbM zDr!0f*%|BD&cSXdL3W2dm2e7~qL0piGtgw Result Result { - // TODO: Now where do I get ctx, text_range, and suppression_action - // from...? - Rule::suppress(); + // println!("Action: {:#?}", action); + // if action.category == ActionCategory::Other { + // return ControlFlow::Break(action); + // } } } } From dd05b076ea2a4e44b87e852ab7baf01d40ffba23 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 26 Sep 2024 00:30:42 -0600 Subject: [PATCH 10/88] WIP --- crates/biome_service/src/file_handlers/javascript.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 53338894a91d..12a1eac13095 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -666,6 +666,9 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { + // No-op, handled above + } FixFileMode::SafeFixes => { if action.applicability == Applicability::MaybeIncorrect { skipped_suggested_fixes += 1; @@ -684,12 +687,6 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { - // println!("Action: {:#?}", action); - // if action.category == ActionCategory::Other { - // return ControlFlow::Break(action); - // } - } } } From c28db57726f7bf9d367ced472c78e76180f1b930 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 26 Sep 2024 00:38:29 -0600 Subject: [PATCH 11/88] WIP --- crates/biome_cli/src/commands/format.rs | 3 --- crates/biome_cli/src/lib.rs | 1 - .../tests/specs/prettier/.DS_Store | Bin 6148 -> 0 bytes .../src/file_handlers/javascript.rs | 4 ++-- 4 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 crates/biome_js_formatter/tests/specs/prettier/.DS_Store diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index bb3960fdc0e8..0438e60f5706 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -33,7 +33,6 @@ pub(crate) struct FormatCommandPayload { pub(crate) files_configuration: Option, pub(crate) stdin_file_path: Option, pub(crate) write: bool, - pub(crate) write_suppressions: bool, pub(crate) fix: bool, pub(crate) cli_options: CliOptions, pub(crate) paths: Vec, @@ -56,7 +55,6 @@ pub(crate) fn format( stdin_file_path, files_configuration, write, - write_suppressions, fix, mut json_formatter, css_formatter, @@ -71,7 +69,6 @@ pub(crate) fn format( apply: false, apply_unsafe: false, write, - write_suppressions, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 19c03ff19246..902beb6721ff 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -222,7 +222,6 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, - write_suppressions, fix, cli_options, paths, diff --git a/crates/biome_js_formatter/tests/specs/prettier/.DS_Store b/crates/biome_js_formatter/tests/specs/prettier/.DS_Store deleted file mode 100644 index 0dbb24996c15ca38935eafe3055982373c73df72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ5Iwu5SRfl=yQQ62?C;6wn&hmTLcX!py4XC+=mp0%Q5fFO`b0ed7 zn*lz%4$Wz~xbBaBoS)c>GS4TAa)P*I@bPf+a{f73=M?3v)mPor)_WQwg^p-Nk5thW zEon-3bc^|_v2XJB)fQK;<2k&p>)5$wy{_M48+Bevom{JnGvEw31N+PXdNxaPtmvaN z;0!ne8wU9MkU|+V!>A~q4h(Vy0Cr&(!JO|BoRb=6hEWk7NYGTErUtuW1WkuMwYbbM zDr!0f*%|BD&cSXdL3W2dm2e7~qL0piGtgw Date: Thu, 26 Sep 2024 01:02:06 -0600 Subject: [PATCH 12/88] WIP --- crates/biome_cli/src/commands/format.rs | 3 +++ crates/biome_cli/src/execute/process_file/assists.rs | 1 + crates/biome_cli/src/execute/process_file/lint.rs | 1 + crates/biome_cli/src/execute/std_in.rs | 1 + crates/biome_cli/src/lib.rs | 1 + crates/biome_lsp/src/handlers/analysis.rs | 1 + crates/biome_service/src/file_handlers/javascript.rs | 4 +--- crates/biome_service/src/file_handlers/mod.rs | 1 + crates/biome_service/src/workspace.rs | 3 +++ crates/biome_service/src/workspace/server.rs | 1 + 10 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 0438e60f5706..bb3960fdc0e8 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -33,6 +33,7 @@ pub(crate) struct FormatCommandPayload { pub(crate) files_configuration: Option, pub(crate) stdin_file_path: Option, pub(crate) write: bool, + pub(crate) write_suppressions: bool, pub(crate) fix: bool, pub(crate) cli_options: CliOptions, pub(crate) paths: Vec, @@ -55,6 +56,7 @@ pub(crate) fn format( stdin_file_path, files_configuration, write, + write_suppressions, fix, mut json_formatter, css_formatter, @@ -69,6 +71,7 @@ pub(crate) fn format( apply: false, apply_unsafe: false, write, + write_suppressions, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/execute/process_file/assists.rs b/crates/biome_cli/src/execute/process_file/assists.rs index 6afe2c6cf1fb..ad931d2ebde9 100644 --- a/crates/biome_cli/src/execute/process_file/assists.rs +++ b/crates/biome_cli/src/execute/process_file/assists.rs @@ -24,6 +24,7 @@ pub(crate) fn assists_with_guard<'ctx>( .guard() .fix_file( FixFileMode::SafeFixes, + ctx.execution.as_write_suppressions_mode().clone().is_some(), false, RuleCategoriesBuilder::default().with_action().build(), only.clone(), diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index b5e4a7db823c..67a4495f826a 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -35,6 +35,7 @@ pub(crate) fn lint_with_guard<'ctx>( .guard() .fix_file( *fix_mode, + ctx.execution.as_write_suppressions_mode().clone().is_some(), false, RuleCategoriesBuilder::default() .with_syntax() diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index cf793abea81d..8ee7815db40f 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -117,6 +117,7 @@ pub(crate) fn run<'a>( if file_features.supports_lint() { let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, + write_suppressions: mode.as_write_suppressions_mode().is_some(), path: biome_path.clone(), should_format: mode.is_check() && file_features.supports_format(), only: only.clone(), diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 902beb6721ff..19c03ff19246 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -222,6 +222,7 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, + write_suppressions, fix, cli_options, paths, diff --git a/crates/biome_lsp/src/handlers/analysis.rs b/crates/biome_lsp/src/handlers/analysis.rs index e115b27479a5..34bcaae54303 100644 --- a/crates/biome_lsp/src/handlers/analysis.rs +++ b/crates/biome_lsp/src/handlers/analysis.rs @@ -242,6 +242,7 @@ fn fix_all( let fixed = session.workspace.fix_file(FixFileParams { path: biome_path, fix_file_mode: FixFileMode::SafeFixes, + write_suppressions: false, should_format, only: vec![], skip: vec![], diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index be46cb3f3750..22804eaeb694 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -659,9 +659,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { pub(crate) parse: AnyParse, pub(crate) fix_file_mode: FixFileMode, + pub(crate) write_suppressions: bool, pub(crate) workspace: WorkspaceSettingsHandle<'a>, /// Whether it should format the code action pub(crate) should_format: bool, diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index 047ec7644d35..84b11d4d3ce3 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -635,6 +635,7 @@ pub enum FixFileMode { pub struct FixFileParams { pub path: BiomePath, pub fix_file_mode: FixFileMode, + pub write_suppressions: bool, pub should_format: bool, pub only: Vec, pub skip: Vec, @@ -1060,6 +1061,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { pub fn fix_file( &self, fix_file_mode: FixFileMode, + write_suppressions: bool, should_format: bool, rule_categories: RuleCategories, only: Vec, @@ -1068,6 +1070,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { self.workspace.fix_file(FixFileParams { path: self.path.clone(), fix_file_mode, + write_suppressions, should_format, only, skip, diff --git a/crates/biome_service/src/workspace/server.rs b/crates/biome_service/src/workspace/server.rs index c8aa6ae6412d..fe2e0fd4a857 100644 --- a/crates/biome_service/src/workspace/server.rs +++ b/crates/biome_service/src/workspace/server.rs @@ -777,6 +777,7 @@ impl Workspace for WorkspaceServer { parse, // rules: rules.as_ref().map(|x| x.borrow()), fix_file_mode: params.fix_file_mode, + write_suppressions: params.write_suppressions, // filter, workspace: self.workspace(), should_format: params.should_format, From a797a8783afe125aafcc79cc691b08829dd7a355 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 26 Sep 2024 01:22:39 -0600 Subject: [PATCH 13/88] WIP --- crates/biome_cli/src/execute/process_file/assists.rs | 2 +- crates/biome_cli/src/execute/process_file/lint.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/biome_cli/src/execute/process_file/assists.rs b/crates/biome_cli/src/execute/process_file/assists.rs index ad931d2ebde9..ab6581900a65 100644 --- a/crates/biome_cli/src/execute/process_file/assists.rs +++ b/crates/biome_cli/src/execute/process_file/assists.rs @@ -24,7 +24,7 @@ pub(crate) fn assists_with_guard<'ctx>( .guard() .fix_file( FixFileMode::SafeFixes, - ctx.execution.as_write_suppressions_mode().clone().is_some(), + ctx.execution.as_write_suppressions_mode().is_some(), false, RuleCategoriesBuilder::default().with_action().build(), only.clone(), diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index 67a4495f826a..e00e8cd7d434 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -35,7 +35,7 @@ pub(crate) fn lint_with_guard<'ctx>( .guard() .fix_file( *fix_mode, - ctx.execution.as_write_suppressions_mode().clone().is_some(), + ctx.execution.as_write_suppressions_mode().is_some(), false, RuleCategoriesBuilder::default() .with_syntax() From f1707a40c6501f785f063d3c32a07bf18b8cd2cf Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 22:24:16 -0600 Subject: [PATCH 14/88] WIP --- .../src/file_handlers/javascript.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 22804eaeb694..853363de5711 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -21,8 +21,8 @@ use crate::{ }; use biome_analyze::options::PreferredQuote; use biome_analyze::{ - AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, QueryMatch, - RuleCategoriesBuilder, RuleCategory, RuleError, RuleFilter, + ActionCategory, AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, + QueryMatch, RuleCategoriesBuilder, RuleCategory, RuleError, RuleFilter, }; use biome_configuration::javascript::JsxRuntime; use biome_diagnostics::{category, Applicability, Diagnostic, DiagnosticExt, Severity}; @@ -659,13 +659,23 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { - // No-op, handled above + if action.applicability == Applicability::Always { + return ControlFlow::Continue(()); + } } FixFileMode::SafeFixes => { if action.applicability == Applicability::MaybeIncorrect { From 046e120db2d906307530866d6402c22c88146298 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 22:43:01 -0600 Subject: [PATCH 15/88] WIP --- crates/biome_cli/src/commands/check.rs | 6 ++-- crates/biome_cli/src/commands/format.rs | 6 ++-- crates/biome_cli/src/commands/lint.rs | 8 +++--- crates/biome_cli/src/commands/migrate.rs | 4 +-- crates/biome_cli/src/commands/mod.rs | 35 +++++++++++++----------- crates/biome_cli/src/execute/mod.rs | 6 ++-- crates/biome_cli/src/lib.rs | 12 ++++---- 7 files changed, 39 insertions(+), 38 deletions(-) diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index 6c8b37aa9866..ae777e4bf0e6 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -28,7 +28,7 @@ pub(crate) struct CheckCommandPayload { pub(crate) apply: bool, pub(crate) apply_unsafe: bool, pub(crate) write: bool, - pub(crate) write_suppressions: bool, + pub(crate) suppress: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -53,7 +53,7 @@ pub(crate) fn check( apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_, cli_options, @@ -75,7 +75,7 @@ pub(crate) fn check( apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index bb3960fdc0e8..9fe1d9d71fdf 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -33,7 +33,7 @@ pub(crate) struct FormatCommandPayload { pub(crate) files_configuration: Option, pub(crate) stdin_file_path: Option, pub(crate) write: bool, - pub(crate) write_suppressions: bool, + pub(crate) suppress: bool, pub(crate) fix: bool, pub(crate) cli_options: CliOptions, pub(crate) paths: Vec, @@ -56,7 +56,7 @@ pub(crate) fn format( stdin_file_path, files_configuration, write, - write_suppressions, + suppress, fix, mut json_formatter, css_formatter, @@ -71,7 +71,7 @@ pub(crate) fn format( apply: false, apply_unsafe: false, write, - write_suppressions, + suppress, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index 871209f57027..1db8eff2e7b1 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -28,7 +28,7 @@ pub(crate) struct LintCommandPayload { pub(crate) apply: bool, pub(crate) apply_unsafe: bool, pub(crate) write: bool, - pub(crate) write_suppressions: bool, + pub(crate) suppress: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -54,6 +54,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply, apply_unsafe, write, + suppress, fix, unsafe_, cli_options, @@ -71,7 +72,6 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( css_linter, json_linter, graphql_linter, - write_suppressions, } = payload; setup_cli_subscriber(cli_options.log_level, cli_options.log_kind); @@ -80,7 +80,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_, }, @@ -184,7 +184,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( only, skip, vcs_targeted: VcsTargeted { staged, changed }, - write_suppressions, + suppress, }) .set_report(&cli_options), session, diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index 6211532817bc..5f4f28193baf 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -13,7 +13,7 @@ pub(crate) fn migrate( session: CliSession, cli_options: CliOptions, write: bool, - write_suppressions: bool, + suppress: bool, fix: bool, sub_command: Option, ) -> Result<(), CliDiagnostic> { @@ -30,7 +30,7 @@ pub(crate) fn migrate( apply: false, apply_unsafe: false, write, - write_suppressions, + suppress, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 977f7eee8efc..57bcefa77ac4 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -107,7 +107,7 @@ pub enum BiomeCommand { /// Writes inline biome-ignore comments to ignore existing diagnostics #[bpaf(long("write"), switch)] - write_suppressions: bool, + suppress: bool, /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] @@ -187,6 +187,9 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, + #[bpaf(long("suppress"))] + suppress: bool, + /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] unsafe_: bool, @@ -224,9 +227,6 @@ pub enum BiomeCommand { #[bpaf(external(partial_graphql_linter), optional, hide_usage, hide)] graphql_linter: Option, - #[bpaf(long("write-suppressions"))] - write_suppressions: bool, - #[bpaf(external, hide_usage)] cli_options: CliOptions, @@ -305,7 +305,10 @@ pub enum BiomeCommand { /// Writes formatted files to file system. #[bpaf(long("write"), switch)] write: bool, - write_suppressions: bool, + + /// Writes inline biome-ignore comments to ignore existing diagnostics + #[bpaf(long("suppress"), switch)] + suppress: bool, /// Alias of `--write`, writes formatted files to file system. #[bpaf(long("fix"), switch, hide_usage)] @@ -736,7 +739,7 @@ pub(crate) struct FixFileModeOptions { apply: bool, apply_unsafe: bool, write: bool, - write_suppressions: bool, + suppress: bool, fix: bool, unsafe_: bool, } @@ -753,7 +756,7 @@ pub(crate) fn determine_fix_file_mode( apply_unsafe, write, fix, - write_suppressions, + suppress, unsafe_, } = options; @@ -778,7 +781,7 @@ pub(crate) fn determine_fix_file_mode( Ok(Some(FixFileMode::SafeAndUnsafeFixes)) } else if safe_fixes { Ok(Some(FixFileMode::SafeFixes)) - } else if write_suppressions { + } else if suppress { Ok(Some(FixFileMode::ApplySuppressions)) } else { Ok(None) @@ -791,7 +794,7 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_, } = options; @@ -817,12 +820,12 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C )); } else if write && fix { return Err(CliDiagnostic::incompatible_arguments("--write", "--fix")); - } else if write_suppressions && write { + } else if suppress && write { return Err(CliDiagnostic::incompatible_arguments( "--write-suppressions", "--write", )); - } else if write_suppressions && fix { + } else if suppress && fix { return Err(CliDiagnostic::incompatible_arguments( "--write-suppressions", "--fix", @@ -839,7 +842,7 @@ mod tests { #[test] fn incompatible_arguments() { - for (apply, apply_unsafe, write, fix, unsafe_) in [ + for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [ (true, true, false, false, false), // --apply --apply-unsafe (true, false, true, false, false), // --apply --write (true, false, false, true, false), // --apply --fix @@ -852,7 +855,7 @@ mod tests { apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_ }) @@ -875,7 +878,7 @@ mod tests { apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_ }, @@ -902,7 +905,7 @@ mod tests { apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_ }, @@ -925,7 +928,7 @@ mod tests { apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_ }, diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index 54f19ff1fc13..f33dec5778f7 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -151,7 +151,7 @@ pub enum TraversalMode { skip: Vec, /// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled vcs_targeted: VcsTargeted, - write_suppressions: bool, + suppress: bool, }, /// This mode is enabled when running the command `biome ci` CI { @@ -307,9 +307,7 @@ impl Execution { pub(crate) fn as_write_suppressions_mode(&self) -> Option<&bool> { match &self.traversal_mode { - TraversalMode::Lint { - write_suppressions, .. - } => Some(write_suppressions), + TraversalMode::Lint { suppress, .. } => Some(suppress), TraversalMode::Check { .. } | TraversalMode::Format { .. } | TraversalMode::CI { .. } diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 19c03ff19246..609e4750f033 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -90,7 +90,7 @@ impl<'app> CliSession<'app> { apply, apply_unsafe, write, - write_suppressions, + suppress, fix, unsafe_, cli_options, @@ -110,7 +110,7 @@ impl<'app> CliSession<'app> { apply_unsafe, apply, write, - write_suppressions, + suppress, fix, unsafe_, cli_options, @@ -130,6 +130,7 @@ impl<'app> CliSession<'app> { apply, apply_unsafe, write, + suppress, fix, unsafe_, cli_options, @@ -147,13 +148,13 @@ impl<'app> CliSession<'app> { javascript_linter, json_linter, graphql_linter, - write_suppressions, } => commands::lint::lint( self, LintCommandPayload { apply_unsafe, apply, write, + suppress, fix, unsafe_, cli_options, @@ -171,7 +172,6 @@ impl<'app> CliSession<'app> { javascript_linter, json_linter, graphql_linter, - write_suppressions, }, ), BiomeCommand::Ci { @@ -203,7 +203,7 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, - write_suppressions, + suppress, fix, cli_options, paths, @@ -222,7 +222,7 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, - write_suppressions, + suppress, fix, cli_options, paths, From 8bb572fadd46d895ddbc54aadb3f44d7de94f1d7 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 22:46:29 -0600 Subject: [PATCH 16/88] WIP --- crates/biome_cli/src/commands/mod.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 57bcefa77ac4..28c9ab6798c4 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -822,14 +822,11 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C return Err(CliDiagnostic::incompatible_arguments("--write", "--fix")); } else if suppress && write { return Err(CliDiagnostic::incompatible_arguments( - "--write-suppressions", + "--suppress", "--write", )); } else if suppress && fix { - return Err(CliDiagnostic::incompatible_arguments( - "--write-suppressions", - "--fix", - )); + return Err(CliDiagnostic::incompatible_arguments("--suppress", "--fix")); } Ok(()) } From 09889d009cb73fc21e6c2e48b4e2d14b70eb1525 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sun, 29 Sep 2024 08:36:20 -0600 Subject: [PATCH 17/88] WIP --- crates/biome_cli/src/execute/std_in.rs | 2 +- crates/biome_lsp/src/handlers/analysis.rs | 2 +- crates/biome_service/src/file_handlers/javascript.rs | 2 +- crates/biome_service/src/file_handlers/mod.rs | 2 +- crates/biome_service/src/workspace.rs | 6 +++--- crates/biome_service/src/workspace/server.rs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index 8ee7815db40f..4e7ec8b1029a 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -117,7 +117,7 @@ pub(crate) fn run<'a>( if file_features.supports_lint() { let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, - write_suppressions: mode.as_write_suppressions_mode().is_some(), + suppress: mode.as_write_suppressions_mode().is_some(), path: biome_path.clone(), should_format: mode.is_check() && file_features.supports_format(), only: only.clone(), diff --git a/crates/biome_lsp/src/handlers/analysis.rs b/crates/biome_lsp/src/handlers/analysis.rs index 34bcaae54303..fc037e7d8c00 100644 --- a/crates/biome_lsp/src/handlers/analysis.rs +++ b/crates/biome_lsp/src/handlers/analysis.rs @@ -242,7 +242,7 @@ fn fix_all( let fixed = session.workspace.fix_file(FixFileParams { path: biome_path, fix_file_mode: FixFileMode::SafeFixes, - write_suppressions: false, + suppress: false, should_format, only: vec![], skip: vec![], diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 853363de5711..5218e74b72c8 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -660,7 +660,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { pub(crate) parse: AnyParse, pub(crate) fix_file_mode: FixFileMode, - pub(crate) write_suppressions: bool, + pub(crate) suppress: bool, pub(crate) workspace: WorkspaceSettingsHandle<'a>, /// Whether it should format the code action pub(crate) should_format: bool, diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index 84b11d4d3ce3..8f72a8556776 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -635,7 +635,7 @@ pub enum FixFileMode { pub struct FixFileParams { pub path: BiomePath, pub fix_file_mode: FixFileMode, - pub write_suppressions: bool, + pub suppress: bool, pub should_format: bool, pub only: Vec, pub skip: Vec, @@ -1061,7 +1061,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { pub fn fix_file( &self, fix_file_mode: FixFileMode, - write_suppressions: bool, + suppress: bool, should_format: bool, rule_categories: RuleCategories, only: Vec, @@ -1070,7 +1070,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { self.workspace.fix_file(FixFileParams { path: self.path.clone(), fix_file_mode, - write_suppressions, + suppress, should_format, only, skip, diff --git a/crates/biome_service/src/workspace/server.rs b/crates/biome_service/src/workspace/server.rs index fe2e0fd4a857..6f232e81d4f9 100644 --- a/crates/biome_service/src/workspace/server.rs +++ b/crates/biome_service/src/workspace/server.rs @@ -777,7 +777,7 @@ impl Workspace for WorkspaceServer { parse, // rules: rules.as_ref().map(|x| x.borrow()), fix_file_mode: params.fix_file_mode, - write_suppressions: params.write_suppressions, + suppress: params.suppress, // filter, workspace: self.workspace(), should_format: params.should_format, From 25af91ce9f2a8db91f58ebe6341d3851331b8541 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sun, 29 Sep 2024 10:55:23 -0600 Subject: [PATCH 18/88] WIP --- crates/biome_cli/src/commands/lint.rs | 3 +++ crates/biome_cli/src/commands/mod.rs | 13 ++++++++++++- crates/biome_cli/src/diagnostics.rs | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index 1db8eff2e7b1..69071cc90751 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -29,6 +29,7 @@ pub(crate) struct LintCommandPayload { pub(crate) apply_unsafe: bool, pub(crate) write: bool, pub(crate) suppress: bool, + pub(crate) suppress_reason: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -55,6 +56,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_, cli_options, @@ -81,6 +83,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply_unsafe, write, suppress, + suppress_reason fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 28c9ab6798c4..5fcdad6aa5f9 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -1,6 +1,8 @@ use crate::changed::{get_changed_files, get_staged_files}; use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg}; -use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile}; +use crate::diagnostics::{ + DeprecatedArgument, DeprecatedConfigurationFile, IncompatibleEndConfiguration, +}; use crate::execute::Stdin; use crate::logging::LoggingKind; use crate::{CliDiagnostic, LoggingLevel, VERSION}; @@ -740,6 +742,7 @@ pub(crate) struct FixFileModeOptions { apply_unsafe: bool, write: bool, suppress: bool, + suppress_reason: Option, fix: bool, unsafe_: bool, } @@ -757,6 +760,7 @@ pub(crate) fn determine_fix_file_mode( write, fix, suppress, + ref suppress_reason, unsafe_, } = options; @@ -795,6 +799,7 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_, } = options; @@ -827,6 +832,12 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C )); } else if suppress && fix { return Err(CliDiagnostic::incompatible_arguments("--suppress", "--fix")); + } else if !suppress && suppress_reason.is_some() { + return Err(CliDiagnostic::IncompatibleEndConfiguration( + IncompatibleEndConfiguration { + reason: "--suppress-reason must be used with --suppress".to_string(), + }, + )); } Ok(()) } diff --git a/crates/biome_cli/src/diagnostics.rs b/crates/biome_cli/src/diagnostics.rs index 48aa995f8261..22bff02828db 100644 --- a/crates/biome_cli/src/diagnostics.rs +++ b/crates/biome_cli/src/diagnostics.rs @@ -223,7 +223,7 @@ pub struct ServerNotRunning; ) )] pub struct IncompatibleEndConfiguration { - reason: String, + pub reason: String, } #[derive(Debug, Diagnostic)] From 3611db0f1b343e428cd3fd859af2ce5060a79e8b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sun, 29 Sep 2024 11:03:29 -0600 Subject: [PATCH 19/88] WIP --- crates/biome_cli/src/commands/check.rs | 3 +++ crates/biome_cli/src/commands/format.rs | 3 +++ crates/biome_cli/src/commands/lint.rs | 4 ++-- crates/biome_cli/src/commands/migrate.rs | 2 ++ crates/biome_cli/src/commands/mod.rs | 19 ++++++++++++++++--- crates/biome_cli/src/lib.rs | 12 ++++++++++-- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index ae777e4bf0e6..416f55c6d456 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -29,6 +29,7 @@ pub(crate) struct CheckCommandPayload { pub(crate) apply_unsafe: bool, pub(crate) write: bool, pub(crate) suppress: bool, + pub(crate) suppress_reason: Option, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -54,6 +55,7 @@ pub(crate) fn check( apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_, cli_options, @@ -76,6 +78,7 @@ pub(crate) fn check( apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 9fe1d9d71fdf..983dfaf97d4b 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -34,6 +34,7 @@ pub(crate) struct FormatCommandPayload { pub(crate) stdin_file_path: Option, pub(crate) write: bool, pub(crate) suppress: bool, + pub(crate) suppress_reason: Option, pub(crate) fix: bool, pub(crate) cli_options: CliOptions, pub(crate) paths: Vec, @@ -57,6 +58,7 @@ pub(crate) fn format( files_configuration, write, suppress, + suppress_reason, fix, mut json_formatter, css_formatter, @@ -72,6 +74,7 @@ pub(crate) fn format( apply_unsafe: false, write, suppress, + suppress_reason, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index 69071cc90751..ef1f285159d6 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -29,7 +29,7 @@ pub(crate) struct LintCommandPayload { pub(crate) apply_unsafe: bool, pub(crate) write: bool, pub(crate) suppress: bool, - pub(crate) suppress_reason: bool, + pub(crate) suppress_reason: Option, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -83,7 +83,7 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply_unsafe, write, suppress, - suppress_reason + suppress_reason, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index 5f4f28193baf..1fa0987f6762 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -14,6 +14,7 @@ pub(crate) fn migrate( cli_options: CliOptions, write: bool, suppress: bool, + suppress_reason: Option, fix: bool, sub_command: Option, ) -> Result<(), CliDiagnostic> { @@ -31,6 +32,7 @@ pub(crate) fn migrate( apply_unsafe: false, write, suppress, + suppress_reason, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 5fcdad6aa5f9..3b4288f34616 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -108,9 +108,12 @@ pub enum BiomeCommand { write: bool, /// Writes inline biome-ignore comments to ignore existing diagnostics - #[bpaf(long("write"), switch)] + #[bpaf(long("suppress"), switch)] suppress: bool, + #[bpaf(long("suppress-reason"))] + suppress_reason: Option, + /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] unsafe_: bool, @@ -192,6 +195,9 @@ pub enum BiomeCommand { #[bpaf(long("suppress"))] suppress: bool, + #[bpaf(long("suppress-reason"))] + suppress_reason: Option, + /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] unsafe_: bool, @@ -312,6 +318,10 @@ pub enum BiomeCommand { #[bpaf(long("suppress"), switch)] suppress: bool, + /// Writes inline biome-ignore comments to ignore existing diagnostics + #[bpaf(long("suppress-reason"))] + suppress_reason: Option, + /// Alias of `--write`, writes formatted files to file system. #[bpaf(long("fix"), switch, hide_usage)] fix: bool, @@ -422,8 +432,11 @@ pub enum BiomeCommand { write: bool, /// Writes inline biome-ignore comments to ignore existing diagnostics - #[bpaf(long("write"), switch)] - write_suppressions: bool, + #[bpaf(long("suppress"), switch)] + suppress: bool, + + #[bpaf(long("suppress-reason"))] + suppress_reason: Option, /// Alias of `--write`, writes the new configuration file to disk #[bpaf(long("fix"), switch, hide_usage)] diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 609e4750f033..297543104cb5 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -91,6 +91,7 @@ impl<'app> CliSession<'app> { apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_, cli_options, @@ -111,6 +112,7 @@ impl<'app> CliSession<'app> { apply, write, suppress, + suppress_reason, fix, unsafe_, cli_options, @@ -131,6 +133,7 @@ impl<'app> CliSession<'app> { apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_, cli_options, @@ -155,6 +158,7 @@ impl<'app> CliSession<'app> { apply, write, suppress, + suppress_reason, fix, unsafe_, cli_options, @@ -204,6 +208,7 @@ impl<'app> CliSession<'app> { stdin_file_path, write, suppress, + suppress_reason, fix, cli_options, paths, @@ -223,6 +228,7 @@ impl<'app> CliSession<'app> { stdin_file_path, write, suppress, + suppress_reason, fix, cli_options, paths, @@ -247,14 +253,16 @@ impl<'app> CliSession<'app> { BiomeCommand::Migrate { cli_options, write, - write_suppressions, + suppress, + suppress_reason, fix, sub_command, } => commands::migrate::migrate( self, cli_options, write, - write_suppressions, + suppress, + suppress_reason, fix, sub_command, ), From 6c6431b944cc40296f3f913a0748eda12991ec5b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sun, 29 Sep 2024 11:15:32 -0600 Subject: [PATCH 20/88] WIP --- crates/biome_service/src/file_handlers/javascript.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 5218e74b72c8..666bf6793ff4 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -673,9 +673,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { - if action.applicability == Applicability::Always { - return ControlFlow::Continue(()); - } + return ControlFlow::Continue(()); } FixFileMode::SafeFixes => { if action.applicability == Applicability::MaybeIncorrect { From 8ddedf4f2425358cf1bf0563849c4570047d21c4 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 30 Sep 2024 14:52:09 -0600 Subject: [PATCH 21/88] WIP --- crates/biome_cli/src/commands/mod.rs | 3 ++- crates/biome_service/src/file_handlers/javascript.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 3b4288f34616..644a6e5721c2 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -111,7 +111,8 @@ pub enum BiomeCommand { #[bpaf(long("suppress"), switch)] suppress: bool, - #[bpaf(long("suppress-reason"))] + /// Reason for suppressing diagnostics with --suppress + #[bpaf(long("reason"))] suppress_reason: Option, /// Allow to do unsafe fixes, should be used with `--write` or `--fix` diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 666bf6793ff4..07adba3ccd31 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -662,7 +662,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result Date: Tue, 1 Oct 2024 21:54:38 -0600 Subject: [PATCH 22/88] WIP --- crates/biome_analyze/src/lib.rs | 2 ++ crates/biome_analyze/src/matcher.rs | 1 + crates/biome_analyze/src/registry.rs | 1 + crates/biome_analyze/src/rule.rs | 2 ++ crates/biome_analyze/src/signals.rs | 14 +++++--- .../biome_analyze/src/suppression_action.rs | 3 ++ crates/biome_cli/src/commands/mod.rs | 34 +++++++++++-------- .../src/execute/process_file/assists.rs | 1 + .../src/execute/process_file/lint.rs | 1 + crates/biome_cli/src/execute/std_in.rs | 1 + .../src/suppression_action.rs | 2 ++ crates/biome_js_analyze/src/lib.rs | 5 ++- .../src/suppression_action.rs | 18 ++++++---- crates/biome_lsp/src/handlers/analysis.rs | 1 + .../src/file_handlers/javascript.rs | 9 ++--- crates/biome_service/src/file_handlers/mod.rs | 1 + crates/biome_service/src/workspace.rs | 3 ++ crates/biome_service/src/workspace/server.rs | 1 + 18 files changed, 66 insertions(+), 34 deletions(-) diff --git a/crates/biome_analyze/src/lib.rs b/crates/biome_analyze/src/lib.rs index ed5e3e2ad914..1b9e9133eddc 100644 --- a/crates/biome_analyze/src/lib.rs +++ b/crates/biome_analyze/src/lib.rs @@ -784,6 +784,8 @@ pub struct SuppressionCommentEmitterPayload<'a, L: Language> { pub mutation: &'a mut BatchMutation, /// A string equals to "rome-ignore: lint(/)" pub suppression_text: &'a str, + /// Reason for the suppression with --suppress + pub suppression_reason: Option, /// The original range of the diagnostic where the rule was triggered pub diagnostic_text_range: &'a TextRange, } diff --git a/crates/biome_analyze/src/matcher.rs b/crates/biome_analyze/src/matcher.rs index f1a101e22fa8..d4c3bd81adf5 100644 --- a/crates/biome_analyze/src/matcher.rs +++ b/crates/biome_analyze/src/matcher.rs @@ -380,6 +380,7 @@ mod tests { _: &mut BatchMutation, _: ApplySuppression, _: &str, + _: Option, ) { unreachable!("") } diff --git a/crates/biome_analyze/src/registry.rs b/crates/biome_analyze/src/registry.rs index dd4121be19ac..7998765bd5e4 100644 --- a/crates/biome_analyze/src/registry.rs +++ b/crates/biome_analyze/src/registry.rs @@ -428,6 +428,7 @@ impl RegistryRule { result, params.services, params.suppression_action, + None, params.options, )); diff --git a/crates/biome_analyze/src/rule.rs b/crates/biome_analyze/src/rule.rs index 4e7b3cc83588..d819069c51b2 100644 --- a/crates/biome_analyze/src/rule.rs +++ b/crates/biome_analyze/src/rule.rs @@ -869,6 +869,7 @@ pub trait Rule: RuleMeta + Sized { ctx: &RuleContext, text_range: &TextRange, suppression_action: &dyn SuppressionAction>, + suppression_reason: Option, ) -> Option>> where Self: 'static, @@ -886,6 +887,7 @@ pub trait Rule: RuleMeta + Sized { let mut mutation = root.begin(); suppression_action.apply_suppression_comment(SuppressionCommentEmitterPayload { suppression_text: suppression_text.as_str(), + suppression_reason, mutation: &mut mutation, token_offset: token, diagnostic_text_range: text_range, diff --git a/crates/biome_analyze/src/signals.rs b/crates/biome_analyze/src/signals.rs index d69e97b77f8b..27785984b1dc 100644 --- a/crates/biome_analyze/src/signals.rs +++ b/crates/biome_analyze/src/signals.rs @@ -310,6 +310,8 @@ pub(crate) struct RuleSignal<'phase, R: Rule> { services: &'phase ServiceBag, /// An optional action to suppress the rule. suppression_action: &'phase dyn SuppressionAction>, + /// An optional reason for suppressing the rule with --suppress + suppression_reason: Option, /// A list of strings that are considered "globals" inside the analyzer options: &'phase AnalyzerOptions, } @@ -326,7 +328,7 @@ where suppression_action: &'phase dyn SuppressionAction< Language = <::Query as Queryable>::Language, >, - + suppression_reason: Option, options: &'phase AnalyzerOptions, ) -> Self { Self { @@ -335,6 +337,7 @@ where state, services, suppression_action, + suppression_reason, options, } } @@ -402,9 +405,12 @@ where }); }; if let Some(text_range) = R::text_range(&ctx, &self.state) { - if let Some(suppression_action) = - R::suppress(&ctx, &text_range, self.suppression_action) - { + if let Some(suppression_action) = R::suppress( + &ctx, + &text_range, + self.suppression_action, + self.suppression_reason.clone(), + ) { let action = AnalyzerAction { rule_name: Some((::NAME, R::METADATA.name)), category: ActionCategory::Other(Cow::Borrowed(SUPPRESSION_ACTION_CATEGORY)), diff --git a/crates/biome_analyze/src/suppression_action.rs b/crates/biome_analyze/src/suppression_action.rs index 8ad8d022bd8f..528f100471a4 100644 --- a/crates/biome_analyze/src/suppression_action.rs +++ b/crates/biome_analyze/src/suppression_action.rs @@ -9,6 +9,7 @@ pub trait SuppressionAction { token_offset, mutation, suppression_text, + suppression_reason, diagnostic_text_range, } = payload; @@ -83,4 +84,6 @@ pub struct ApplySuppression { pub token_to_apply_suppression: SyntaxToken, /// If the suppression should have a leading newline pub should_insert_leading_newline: bool, + /// Explanation for the suppression with --suppress + pub suppression_reason: Option, } diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 644a6e5721c2..cc5189abdead 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -196,7 +196,7 @@ pub enum BiomeCommand { #[bpaf(long("suppress"))] suppress: bool, - #[bpaf(long("suppress-reason"))] + #[bpaf(long("reason"))] suppress_reason: Option, /// Allow to do unsafe fixes, should be used with `--write` or `--fix` @@ -774,7 +774,7 @@ pub(crate) fn determine_fix_file_mode( write, fix, suppress, - ref suppress_reason, + suppress_reason: _, unsafe_, } = options; @@ -864,20 +864,21 @@ mod tests { #[test] fn incompatible_arguments() { - for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [ - (true, true, false, false, false), // --apply --apply-unsafe - (true, false, true, false, false), // --apply --write - (true, false, false, true, false), // --apply --fix - (false, true, false, false, true), // --apply-unsafe --unsafe - (false, true, true, false, false), // --apply-unsafe --write - (false, true, false, true, false), // --apply-unsafe --fix - (false, false, true, true, false), // --write --fix + for (apply, apply_unsafe, write, suppress, suppression_reason, fix, unsafe_) in [ + (true, true, false, None, false, false), // --apply --apply-unsafe + (true, false, true, None, false, false), // --apply --write + (true, false, false, None, true, false), // --apply --fix + (false, true, false, None, false, true), // --apply-unsafe --unsafe + (false, true, true, None, false, false), // --apply-unsafe --write + (false, true, false, None, true, false), // --apply-unsafe --fix + (false, false, true, None, true, false), // --write --fix ] { assert!(check_fix_incompatible_arguments(FixFileModeOptions { apply, apply_unsafe, write, suppress, + suppress_reason: None, fix, unsafe_ }) @@ -916,10 +917,10 @@ mod tests { fn safe_and_unsafe_fixes() { let mut console = BufferConsole::default(); - for (apply, apply_unsafe, write, fix, unsafe_) in [ - (false, true, false, false, false), // --apply-unsafe - (false, false, true, false, true), // --write --unsafe - (false, false, false, true, true), // --fix --unsafe + for (apply, apply_unsafe, write, suppress, suppress_reason, fix, unsafe_) in [ + (false, true, false, false, None, false, false), // --apply-unsafe + (false, false, true, false, None, false, true), // --write --unsafe + (false, false, false, false, None, true, true), // --fix --unsafe ] { assert_eq!( determine_fix_file_mode( @@ -928,6 +929,7 @@ mod tests { apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_ }, @@ -943,7 +945,8 @@ mod tests { fn no_fix() { let mut console = BufferConsole::default(); - let (apply, apply_unsafe, write, fix, unsafe_) = (false, false, false, false, false); + let (apply, apply_unsafe, write, suppress, suppress_reason, fix, unsafe_) = + (false, false, false, false, None, false, false); assert_eq!( determine_fix_file_mode( FixFileModeOptions { @@ -951,6 +954,7 @@ mod tests { apply_unsafe, write, suppress, + suppress_reason, fix, unsafe_ }, diff --git a/crates/biome_cli/src/execute/process_file/assists.rs b/crates/biome_cli/src/execute/process_file/assists.rs index ab6581900a65..5251e081be0b 100644 --- a/crates/biome_cli/src/execute/process_file/assists.rs +++ b/crates/biome_cli/src/execute/process_file/assists.rs @@ -25,6 +25,7 @@ pub(crate) fn assists_with_guard<'ctx>( .fix_file( FixFileMode::SafeFixes, ctx.execution.as_write_suppressions_mode().is_some(), + None, false, RuleCategoriesBuilder::default().with_action().build(), only.clone(), diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index e00e8cd7d434..5bd77547da7a 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -36,6 +36,7 @@ pub(crate) fn lint_with_guard<'ctx>( .fix_file( *fix_mode, ctx.execution.as_write_suppressions_mode().is_some(), + None, false, RuleCategoriesBuilder::default() .with_syntax() diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index 4e7ec8b1029a..5363916755b6 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -118,6 +118,7 @@ pub(crate) fn run<'a>( let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, suppress: mode.as_write_suppressions_mode().is_some(), + suppression_reason: None, path: biome_path.clone(), should_format: mode.is_check() && file_features.supports_format(), only: only.clone(), diff --git a/crates/biome_css_analyze/src/suppression_action.rs b/crates/biome_css_analyze/src/suppression_action.rs index 464d959b279d..16a1c7f861ef 100644 --- a/crates/biome_css_analyze/src/suppression_action.rs +++ b/crates/biome_css_analyze/src/suppression_action.rs @@ -15,6 +15,7 @@ impl SuppressionAction for CssSuppressionAction { token_has_trailing_comments: false, token_to_apply_suppression: token.clone(), should_insert_leading_newline: false, + suppression_reason: None, }; let mut current_token = token; loop { @@ -46,6 +47,7 @@ impl SuppressionAction for CssSuppressionAction { token_to_apply_suppression, token_has_trailing_comments, should_insert_leading_newline: _, + suppression_reason: _, } = apply_suppression; let mut new_token = token_to_apply_suppression.clone(); diff --git a/crates/biome_js_analyze/src/lib.rs b/crates/biome_js_analyze/src/lib.rs index 50b8e00f6176..d9b058a53c1f 100644 --- a/crates/biome_js_analyze/src/lib.rs +++ b/crates/biome_js_analyze/src/lib.rs @@ -245,6 +245,7 @@ mod tests { ControlFlow::::Continue(()) }, + suppression_reason, ); // assert_eq!(error_ranges.as_slice(), &[]); @@ -340,6 +341,7 @@ mod tests { ControlFlow::::Continue(()) }, + suppress_reason, ); assert_eq!( lint_ranges.as_slice(), @@ -412,6 +414,7 @@ mod tests { ControlFlow::::Continue(()) }, - ); + suppress_reason, + ) } } diff --git a/crates/biome_js_analyze/src/suppression_action.rs b/crates/biome_js_analyze/src/suppression_action.rs index b86f20ee5532..445d8a935eee 100644 --- a/crates/biome_js_analyze/src/suppression_action.rs +++ b/crates/biome_js_analyze/src/suppression_action.rs @@ -58,6 +58,7 @@ impl SuppressionAction for JsSuppressionAction { token_has_trailing_comments: false, token_to_apply_suppression: token.clone(), should_insert_leading_newline: false, + suppression_reason: None, }; let mut current_token = token; let mut should_insert_leading_newline = loop { @@ -134,6 +135,7 @@ impl SuppressionAction for JsSuppressionAction { token_to_apply_suppression, token_has_trailing_comments, should_insert_leading_newline, + suppression_reason, } = apply_suppression; // we check if the token that has the newline is inside a JSX element: JsxOpeningElement or JsxSelfClosingElement @@ -145,6 +147,8 @@ impl SuppressionAction for JsSuppressionAction { } }); + let explanation = suppression_reason.unwrap_or_else(|| "".to_string()); + // When inside a JSX element, we have to apply different logics when applying suppression comments. // Newlines are inside JsxText. if let Some(current_jsx_element) = current_jsx_element { @@ -156,7 +160,7 @@ impl SuppressionAction for JsSuppressionAction { let jsx_comment = jsx_expression_child( token(T!['{']).with_trailing_trivia([( TriviaPieceKind::SingleLineComment, - format!("/* {suppression_text}: */").as_str(), + format!("/* {suppression_text}: {explanation} */").as_str(), )]), token(T!['}']), ) @@ -193,7 +197,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: ").as_str(), + format!("// {suppression_text}: {explanation}").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -201,7 +205,7 @@ impl SuppressionAction for JsSuppressionAction { new_token = new_token.with_leading_trivia([ ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: ").as_str(), + format!("// {suppression_text}: {explanation}").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -216,7 +220,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: ").as_str(), + format!("// {suppression_text}: {explanation}").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -225,7 +229,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: ").as_str(), + format!("// {suppression_text}: {explanation}").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -234,12 +238,12 @@ impl SuppressionAction for JsSuppressionAction { new_token = new_token.with_trailing_trivia([ ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: ").as_str(), + format!("// {suppression_text}: {explanation}").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) } else { - let comment = format!("// {suppression_text}: "); + let comment = format!("// {suppression_text}: {explanation}"); let mut trivia = vec![ (TriviaPieceKind::SingleLineComment, comment.as_str()), (TriviaPieceKind::Newline, "\n"), diff --git a/crates/biome_lsp/src/handlers/analysis.rs b/crates/biome_lsp/src/handlers/analysis.rs index fc037e7d8c00..0c9ffdab87c8 100644 --- a/crates/biome_lsp/src/handlers/analysis.rs +++ b/crates/biome_lsp/src/handlers/analysis.rs @@ -243,6 +243,7 @@ fn fix_all( path: biome_path, fix_file_mode: FixFileMode::SafeFixes, suppress: false, + suppression_reason: None, should_format, only: vec![], skip: vec![], diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 07adba3ccd31..c092b75e09fc 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -21,8 +21,8 @@ use crate::{ }; use biome_analyze::options::PreferredQuote; use biome_analyze::{ - ActionCategory, AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, - QueryMatch, RuleCategoriesBuilder, RuleCategory, RuleError, RuleFilter, + AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, QueryMatch, + RuleCategoriesBuilder, RuleCategory, RuleError, RuleFilter, }; use biome_configuration::javascript::JsxRuntime; use biome_diagnostics::{category, Applicability, Diagnostic, DiagnosticExt, Severity}; @@ -662,11 +662,6 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { pub(crate) parse: AnyParse, pub(crate) fix_file_mode: FixFileMode, pub(crate) suppress: bool, + pub(crate) suppression_reason: Option, pub(crate) workspace: WorkspaceSettingsHandle<'a>, /// Whether it should format the code action pub(crate) should_format: bool, diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index 8f72a8556776..5b8b4ceb315e 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -636,6 +636,7 @@ pub struct FixFileParams { pub path: BiomePath, pub fix_file_mode: FixFileMode, pub suppress: bool, + pub suppression_reason: Option, pub should_format: bool, pub only: Vec, pub skip: Vec, @@ -1062,6 +1063,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { &self, fix_file_mode: FixFileMode, suppress: bool, + suppression_reason: Option, should_format: bool, rule_categories: RuleCategories, only: Vec, @@ -1071,6 +1073,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { path: self.path.clone(), fix_file_mode, suppress, + suppression_reason, should_format, only, skip, diff --git a/crates/biome_service/src/workspace/server.rs b/crates/biome_service/src/workspace/server.rs index 6f232e81d4f9..82055ecd33ab 100644 --- a/crates/biome_service/src/workspace/server.rs +++ b/crates/biome_service/src/workspace/server.rs @@ -778,6 +778,7 @@ impl Workspace for WorkspaceServer { // rules: rules.as_ref().map(|x| x.borrow()), fix_file_mode: params.fix_file_mode, suppress: params.suppress, + suppression_reason: params.suppression_reason, // filter, workspace: self.workspace(), should_format: params.should_format, From 86560e95797d3f9cba521da346c722e5189f2fd4 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 22:43:35 -0600 Subject: [PATCH 23/88] WIP --- crates/biome_analyze/src/lib.rs | 2 -- crates/biome_analyze/src/matcher.rs | 1 - crates/biome_analyze/src/registry.rs | 1 - crates/biome_analyze/src/rule.rs | 2 -- crates/biome_analyze/src/signals.rs | 13 +++---------- crates/biome_analyze/src/suppression_action.rs | 1 - crates/biome_service/src/file_handlers/mod.rs | 1 - crates/biome_service/src/workspace/server.rs | 1 - 8 files changed, 3 insertions(+), 19 deletions(-) diff --git a/crates/biome_analyze/src/lib.rs b/crates/biome_analyze/src/lib.rs index 1b9e9133eddc..ed5e3e2ad914 100644 --- a/crates/biome_analyze/src/lib.rs +++ b/crates/biome_analyze/src/lib.rs @@ -784,8 +784,6 @@ pub struct SuppressionCommentEmitterPayload<'a, L: Language> { pub mutation: &'a mut BatchMutation, /// A string equals to "rome-ignore: lint(/)" pub suppression_text: &'a str, - /// Reason for the suppression with --suppress - pub suppression_reason: Option, /// The original range of the diagnostic where the rule was triggered pub diagnostic_text_range: &'a TextRange, } diff --git a/crates/biome_analyze/src/matcher.rs b/crates/biome_analyze/src/matcher.rs index d4c3bd81adf5..f1a101e22fa8 100644 --- a/crates/biome_analyze/src/matcher.rs +++ b/crates/biome_analyze/src/matcher.rs @@ -380,7 +380,6 @@ mod tests { _: &mut BatchMutation, _: ApplySuppression, _: &str, - _: Option, ) { unreachable!("") } diff --git a/crates/biome_analyze/src/registry.rs b/crates/biome_analyze/src/registry.rs index 7998765bd5e4..dd4121be19ac 100644 --- a/crates/biome_analyze/src/registry.rs +++ b/crates/biome_analyze/src/registry.rs @@ -428,7 +428,6 @@ impl RegistryRule { result, params.services, params.suppression_action, - None, params.options, )); diff --git a/crates/biome_analyze/src/rule.rs b/crates/biome_analyze/src/rule.rs index d819069c51b2..4e7b3cc83588 100644 --- a/crates/biome_analyze/src/rule.rs +++ b/crates/biome_analyze/src/rule.rs @@ -869,7 +869,6 @@ pub trait Rule: RuleMeta + Sized { ctx: &RuleContext, text_range: &TextRange, suppression_action: &dyn SuppressionAction>, - suppression_reason: Option, ) -> Option>> where Self: 'static, @@ -887,7 +886,6 @@ pub trait Rule: RuleMeta + Sized { let mut mutation = root.begin(); suppression_action.apply_suppression_comment(SuppressionCommentEmitterPayload { suppression_text: suppression_text.as_str(), - suppression_reason, mutation: &mut mutation, token_offset: token, diagnostic_text_range: text_range, diff --git a/crates/biome_analyze/src/signals.rs b/crates/biome_analyze/src/signals.rs index 27785984b1dc..7c97ba9374cc 100644 --- a/crates/biome_analyze/src/signals.rs +++ b/crates/biome_analyze/src/signals.rs @@ -310,8 +310,6 @@ pub(crate) struct RuleSignal<'phase, R: Rule> { services: &'phase ServiceBag, /// An optional action to suppress the rule. suppression_action: &'phase dyn SuppressionAction>, - /// An optional reason for suppressing the rule with --suppress - suppression_reason: Option, /// A list of strings that are considered "globals" inside the analyzer options: &'phase AnalyzerOptions, } @@ -328,7 +326,6 @@ where suppression_action: &'phase dyn SuppressionAction< Language = <::Query as Queryable>::Language, >, - suppression_reason: Option, options: &'phase AnalyzerOptions, ) -> Self { Self { @@ -337,7 +334,6 @@ where state, services, suppression_action, - suppression_reason, options, } } @@ -405,12 +401,9 @@ where }); }; if let Some(text_range) = R::text_range(&ctx, &self.state) { - if let Some(suppression_action) = R::suppress( - &ctx, - &text_range, - self.suppression_action, - self.suppression_reason.clone(), - ) { + if let Some(suppression_action) = + R::suppress(&ctx, &text_range, self.suppression_action) + { let action = AnalyzerAction { rule_name: Some((::NAME, R::METADATA.name)), category: ActionCategory::Other(Cow::Borrowed(SUPPRESSION_ACTION_CATEGORY)), diff --git a/crates/biome_analyze/src/suppression_action.rs b/crates/biome_analyze/src/suppression_action.rs index 528f100471a4..e6d214d9a5ae 100644 --- a/crates/biome_analyze/src/suppression_action.rs +++ b/crates/biome_analyze/src/suppression_action.rs @@ -9,7 +9,6 @@ pub trait SuppressionAction { token_offset, mutation, suppression_text, - suppression_reason, diagnostic_text_range, } = payload; diff --git a/crates/biome_service/src/file_handlers/mod.rs b/crates/biome_service/src/file_handlers/mod.rs index 0c8ac4cd9997..6a676bab95e9 100644 --- a/crates/biome_service/src/file_handlers/mod.rs +++ b/crates/biome_service/src/file_handlers/mod.rs @@ -358,7 +358,6 @@ pub struct FixAllParams<'a> { pub(crate) parse: AnyParse, pub(crate) fix_file_mode: FixFileMode, pub(crate) suppress: bool, - pub(crate) suppression_reason: Option, pub(crate) workspace: WorkspaceSettingsHandle<'a>, /// Whether it should format the code action pub(crate) should_format: bool, diff --git a/crates/biome_service/src/workspace/server.rs b/crates/biome_service/src/workspace/server.rs index 82055ecd33ab..6f232e81d4f9 100644 --- a/crates/biome_service/src/workspace/server.rs +++ b/crates/biome_service/src/workspace/server.rs @@ -778,7 +778,6 @@ impl Workspace for WorkspaceServer { // rules: rules.as_ref().map(|x| x.borrow()), fix_file_mode: params.fix_file_mode, suppress: params.suppress, - suppression_reason: params.suppression_reason, // filter, workspace: self.workspace(), should_format: params.should_format, From 1b44843118b4aa486324d13a9307dfd68566b2a3 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 22:45:10 -0600 Subject: [PATCH 24/88] WIP --- .../biome_analyze/src/suppression_action.rs | 2 -- .../src/suppression_action.rs | 2 -- .../src/suppression_action.rs | 28 ++++++++----------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/crates/biome_analyze/src/suppression_action.rs b/crates/biome_analyze/src/suppression_action.rs index e6d214d9a5ae..8ad8d022bd8f 100644 --- a/crates/biome_analyze/src/suppression_action.rs +++ b/crates/biome_analyze/src/suppression_action.rs @@ -83,6 +83,4 @@ pub struct ApplySuppression { pub token_to_apply_suppression: SyntaxToken, /// If the suppression should have a leading newline pub should_insert_leading_newline: bool, - /// Explanation for the suppression with --suppress - pub suppression_reason: Option, } diff --git a/crates/biome_css_analyze/src/suppression_action.rs b/crates/biome_css_analyze/src/suppression_action.rs index 16a1c7f861ef..464d959b279d 100644 --- a/crates/biome_css_analyze/src/suppression_action.rs +++ b/crates/biome_css_analyze/src/suppression_action.rs @@ -15,7 +15,6 @@ impl SuppressionAction for CssSuppressionAction { token_has_trailing_comments: false, token_to_apply_suppression: token.clone(), should_insert_leading_newline: false, - suppression_reason: None, }; let mut current_token = token; loop { @@ -47,7 +46,6 @@ impl SuppressionAction for CssSuppressionAction { token_to_apply_suppression, token_has_trailing_comments, should_insert_leading_newline: _, - suppression_reason: _, } = apply_suppression; let mut new_token = token_to_apply_suppression.clone(); diff --git a/crates/biome_js_analyze/src/suppression_action.rs b/crates/biome_js_analyze/src/suppression_action.rs index 445d8a935eee..c040b423bdb6 100644 --- a/crates/biome_js_analyze/src/suppression_action.rs +++ b/crates/biome_js_analyze/src/suppression_action.rs @@ -13,12 +13,12 @@ use biome_rowan::{AstNode, BatchMutation, TriviaPieceKind}; /// This new element will serve as trailing "newline" for the suppression comment. fn make_indentation_from_jsx_element(current_element: &JsxText) -> JsxText { if let Ok(text) = current_element.value_token() { - let chars = text.text().chars(); + let bytes = text.text().bytes(); let mut newlines = 0; let mut spaces = 0; let mut string_found = false; - for char in chars { - if char == '\"' { + for byte in bytes { + if byte == b'\"' { if string_found { string_found = false; } else { @@ -30,10 +30,10 @@ fn make_indentation_from_jsx_element(current_element: &JsxText) -> JsxText { continue; } - if matches!(char, '\r' | '\n') { + if matches!(byte, b'\r' | b'\n') { newlines += 1; } - if matches!(char, ' ') && newlines == 1 && !string_found { + if matches!(byte, b' ') && newlines == 1 && !string_found { spaces += 1; } } @@ -58,7 +58,6 @@ impl SuppressionAction for JsSuppressionAction { token_has_trailing_comments: false, token_to_apply_suppression: token.clone(), should_insert_leading_newline: false, - suppression_reason: None, }; let mut current_token = token; let mut should_insert_leading_newline = loop { @@ -135,7 +134,6 @@ impl SuppressionAction for JsSuppressionAction { token_to_apply_suppression, token_has_trailing_comments, should_insert_leading_newline, - suppression_reason, } = apply_suppression; // we check if the token that has the newline is inside a JSX element: JsxOpeningElement or JsxSelfClosingElement @@ -147,8 +145,6 @@ impl SuppressionAction for JsSuppressionAction { } }); - let explanation = suppression_reason.unwrap_or_else(|| "".to_string()); - // When inside a JSX element, we have to apply different logics when applying suppression comments. // Newlines are inside JsxText. if let Some(current_jsx_element) = current_jsx_element { @@ -160,7 +156,7 @@ impl SuppressionAction for JsSuppressionAction { let jsx_comment = jsx_expression_child( token(T!['{']).with_trailing_trivia([( TriviaPieceKind::SingleLineComment, - format!("/* {suppression_text}: {explanation} */").as_str(), + format!("/* {suppression_text}: */").as_str(), )]), token(T!['}']), ) @@ -197,7 +193,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: {explanation}").as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -205,7 +201,7 @@ impl SuppressionAction for JsSuppressionAction { new_token = new_token.with_leading_trivia([ ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: {explanation}").as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -220,7 +216,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: {explanation}").as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -229,7 +225,7 @@ impl SuppressionAction for JsSuppressionAction { (TriviaPieceKind::Newline, "\n"), ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: {explanation}").as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) @@ -238,12 +234,12 @@ impl SuppressionAction for JsSuppressionAction { new_token = new_token.with_trailing_trivia([ ( TriviaPieceKind::SingleLineComment, - format!("// {suppression_text}: {explanation}").as_str(), + format!("// {suppression_text}: ").as_str(), ), (TriviaPieceKind::Newline, "\n"), ]) } else { - let comment = format!("// {suppression_text}: {explanation}"); + let comment = format!("// {suppression_text}: "); let mut trivia = vec![ (TriviaPieceKind::SingleLineComment, comment.as_str()), (TriviaPieceKind::Newline, "\n"), From 88bfa71e79151bda2fb2620762550c5f6ff630b5 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 22:56:50 -0600 Subject: [PATCH 25/88] WIP --- crates/biome_cli/src/commands/check.rs | 7 +-- crates/biome_cli/src/commands/format.rs | 7 +-- crates/biome_cli/src/commands/lint.rs | 3 -- crates/biome_cli/src/commands/migrate.rs | 5 +- crates/biome_cli/src/commands/mod.rs | 65 +++++------------------- crates/biome_cli/src/lib.rs | 22 +------- 6 files changed, 17 insertions(+), 92 deletions(-) diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index 416f55c6d456..89d9824ac6f1 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -28,8 +28,6 @@ pub(crate) struct CheckCommandPayload { pub(crate) apply: bool, pub(crate) apply_unsafe: bool, pub(crate) write: bool, - pub(crate) suppress: bool, - pub(crate) suppress_reason: Option, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -54,8 +52,6 @@ pub(crate) fn check( apply, apply_unsafe, write, - suppress, - suppress_reason, fix, unsafe_, cli_options, @@ -77,8 +73,7 @@ pub(crate) fn check( apply, apply_unsafe, write, - suppress, - suppress_reason, + suppress: false, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 983dfaf97d4b..9611a4e22e28 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -33,8 +33,6 @@ pub(crate) struct FormatCommandPayload { pub(crate) files_configuration: Option, pub(crate) stdin_file_path: Option, pub(crate) write: bool, - pub(crate) suppress: bool, - pub(crate) suppress_reason: Option, pub(crate) fix: bool, pub(crate) cli_options: CliOptions, pub(crate) paths: Vec, @@ -57,8 +55,6 @@ pub(crate) fn format( stdin_file_path, files_configuration, write, - suppress, - suppress_reason, fix, mut json_formatter, css_formatter, @@ -73,8 +69,7 @@ pub(crate) fn format( apply: false, apply_unsafe: false, write, - suppress, - suppress_reason, + suppress: false, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index ef1f285159d6..1db8eff2e7b1 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -29,7 +29,6 @@ pub(crate) struct LintCommandPayload { pub(crate) apply_unsafe: bool, pub(crate) write: bool, pub(crate) suppress: bool, - pub(crate) suppress_reason: Option, pub(crate) fix: bool, pub(crate) unsafe_: bool, pub(crate) cli_options: CliOptions, @@ -56,7 +55,6 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply_unsafe, write, suppress, - suppress_reason, fix, unsafe_, cli_options, @@ -83,7 +81,6 @@ pub(crate) fn lint(session: CliSession, payload: LintCommandPayload) -> Result<( apply_unsafe, write, suppress, - suppress_reason, fix, unsafe_, }, diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index 1fa0987f6762..1d0d1f48ecaf 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -13,8 +13,6 @@ pub(crate) fn migrate( session: CliSession, cli_options: CliOptions, write: bool, - suppress: bool, - suppress_reason: Option, fix: bool, sub_command: Option, ) -> Result<(), CliDiagnostic> { @@ -31,8 +29,7 @@ pub(crate) fn migrate( apply: false, apply_unsafe: false, write, - suppress, - suppress_reason, + suppress: false, fix, unsafe_: false, })?; diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index cc5189abdead..2cbcab4e10ec 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -1,8 +1,6 @@ use crate::changed::{get_changed_files, get_staged_files}; use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg}; -use crate::diagnostics::{ - DeprecatedArgument, DeprecatedConfigurationFile, IncompatibleEndConfiguration, -}; +use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile}; use crate::execute::Stdin; use crate::logging::LoggingKind; use crate::{CliDiagnostic, LoggingLevel, VERSION}; @@ -107,14 +105,6 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, - /// Writes inline biome-ignore comments to ignore existing diagnostics - #[bpaf(long("suppress"), switch)] - suppress: bool, - - /// Reason for suppressing diagnostics with --suppress - #[bpaf(long("reason"))] - suppress_reason: Option, - /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] unsafe_: bool, @@ -196,9 +186,6 @@ pub enum BiomeCommand { #[bpaf(long("suppress"))] suppress: bool, - #[bpaf(long("reason"))] - suppress_reason: Option, - /// Allow to do unsafe fixes, should be used with `--write` or `--fix` #[bpaf(long("unsafe"), switch)] unsafe_: bool, @@ -315,14 +302,6 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, - /// Writes inline biome-ignore comments to ignore existing diagnostics - #[bpaf(long("suppress"), switch)] - suppress: bool, - - /// Writes inline biome-ignore comments to ignore existing diagnostics - #[bpaf(long("suppress-reason"))] - suppress_reason: Option, - /// Alias of `--write`, writes formatted files to file system. #[bpaf(long("fix"), switch, hide_usage)] fix: bool, @@ -432,13 +411,6 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, - /// Writes inline biome-ignore comments to ignore existing diagnostics - #[bpaf(long("suppress"), switch)] - suppress: bool, - - #[bpaf(long("suppress-reason"))] - suppress_reason: Option, - /// Alias of `--write`, writes the new configuration file to disk #[bpaf(long("fix"), switch, hide_usage)] fix: bool, @@ -756,7 +728,6 @@ pub(crate) struct FixFileModeOptions { apply_unsafe: bool, write: bool, suppress: bool, - suppress_reason: Option, fix: bool, unsafe_: bool, } @@ -774,7 +745,6 @@ pub(crate) fn determine_fix_file_mode( write, fix, suppress, - suppress_reason: _, unsafe_, } = options; @@ -813,7 +783,6 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C apply_unsafe, write, suppress, - suppress_reason, fix, unsafe_, } = options; @@ -846,12 +815,6 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C )); } else if suppress && fix { return Err(CliDiagnostic::incompatible_arguments("--suppress", "--fix")); - } else if !suppress && suppress_reason.is_some() { - return Err(CliDiagnostic::IncompatibleEndConfiguration( - IncompatibleEndConfiguration { - reason: "--suppress-reason must be used with --suppress".to_string(), - }, - )); } Ok(()) } @@ -864,21 +827,20 @@ mod tests { #[test] fn incompatible_arguments() { - for (apply, apply_unsafe, write, suppress, suppression_reason, fix, unsafe_) in [ - (true, true, false, None, false, false), // --apply --apply-unsafe - (true, false, true, None, false, false), // --apply --write - (true, false, false, None, true, false), // --apply --fix - (false, true, false, None, false, true), // --apply-unsafe --unsafe - (false, true, true, None, false, false), // --apply-unsafe --write - (false, true, false, None, true, false), // --apply-unsafe --fix - (false, false, true, None, true, false), // --write --fix + for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [ + (true, true, false, false, false, false), // --apply --apply-unsafe + (true, false, true, false, false, false), // --apply --write + (true, false, false, false, true, false), // --apply --fix + (false, true, false, false, false, true), // --apply-unsafe --unsafe + (false, true, true, false, false, false), // --apply-unsafe --write + (false, true, false, false, true, false), // --apply-unsafe --fix + (false, false, true, false, true, false), // --write --fix ] { assert!(check_fix_incompatible_arguments(FixFileModeOptions { apply, apply_unsafe, write, suppress, - suppress_reason: None, fix, unsafe_ }) @@ -890,10 +852,10 @@ mod tests { fn safe_fixes() { let mut console = BufferConsole::default(); - for (apply, apply_unsafe, write, fix, unsafe_) in [ - (true, false, false, false, false), // --apply - (false, false, true, false, false), // --write - (false, false, false, true, false), // --fix + for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [ + (true, false, false, false, false, false), // --apply + (false, false, true, false, false, false), // --write + (false, false, false, false, true, false), // --fix ] { assert_eq!( determine_fix_file_mode( @@ -929,7 +891,6 @@ mod tests { apply_unsafe, write, suppress, - suppress_reason, fix, unsafe_ }, diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 297543104cb5..a7415e425f6d 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -90,8 +90,6 @@ impl<'app> CliSession<'app> { apply, apply_unsafe, write, - suppress, - suppress_reason, fix, unsafe_, cli_options, @@ -111,8 +109,6 @@ impl<'app> CliSession<'app> { apply_unsafe, apply, write, - suppress, - suppress_reason, fix, unsafe_, cli_options, @@ -133,7 +129,6 @@ impl<'app> CliSession<'app> { apply_unsafe, write, suppress, - suppress_reason, fix, unsafe_, cli_options, @@ -158,7 +153,6 @@ impl<'app> CliSession<'app> { apply, write, suppress, - suppress_reason, fix, unsafe_, cli_options, @@ -207,8 +201,6 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, - suppress, - suppress_reason, fix, cli_options, paths, @@ -227,8 +219,6 @@ impl<'app> CliSession<'app> { formatter_configuration, stdin_file_path, write, - suppress, - suppress_reason, fix, cli_options, paths, @@ -253,19 +243,9 @@ impl<'app> CliSession<'app> { BiomeCommand::Migrate { cli_options, write, - suppress, - suppress_reason, - fix, - sub_command, - } => commands::migrate::migrate( - self, - cli_options, - write, - suppress, - suppress_reason, fix, sub_command, - ), + } => commands::migrate::migrate(self, cli_options, write, fix, sub_command), BiomeCommand::Search { cli_options, files_configuration, From f754916383cb89cf506a977141ee9058d592e9f8 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:01:38 -0600 Subject: [PATCH 26/88] WIP --- crates/biome_analyze/src/signals.rs | 1 + crates/biome_cli/src/diagnostics.rs | 2 +- crates/biome_js_analyze/src/lib.rs | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/biome_analyze/src/signals.rs b/crates/biome_analyze/src/signals.rs index 7c97ba9374cc..d69e97b77f8b 100644 --- a/crates/biome_analyze/src/signals.rs +++ b/crates/biome_analyze/src/signals.rs @@ -326,6 +326,7 @@ where suppression_action: &'phase dyn SuppressionAction< Language = <::Query as Queryable>::Language, >, + options: &'phase AnalyzerOptions, ) -> Self { Self { diff --git a/crates/biome_cli/src/diagnostics.rs b/crates/biome_cli/src/diagnostics.rs index 22bff02828db..48aa995f8261 100644 --- a/crates/biome_cli/src/diagnostics.rs +++ b/crates/biome_cli/src/diagnostics.rs @@ -223,7 +223,7 @@ pub struct ServerNotRunning; ) )] pub struct IncompatibleEndConfiguration { - pub reason: String, + reason: String, } #[derive(Debug, Diagnostic)] diff --git a/crates/biome_js_analyze/src/lib.rs b/crates/biome_js_analyze/src/lib.rs index d9b058a53c1f..50b8e00f6176 100644 --- a/crates/biome_js_analyze/src/lib.rs +++ b/crates/biome_js_analyze/src/lib.rs @@ -245,7 +245,6 @@ mod tests { ControlFlow::::Continue(()) }, - suppression_reason, ); // assert_eq!(error_ranges.as_slice(), &[]); @@ -341,7 +340,6 @@ mod tests { ControlFlow::::Continue(()) }, - suppress_reason, ); assert_eq!( lint_ranges.as_slice(), @@ -414,7 +412,6 @@ mod tests { ControlFlow::::Continue(()) }, - suppress_reason, - ) + ); } } From 0e1a789051b32e9e251c198dd516130f58c2b2dd Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:03:42 -0600 Subject: [PATCH 27/88] WIP --- crates/biome_cli/src/execute/process_file/assists.rs | 1 - crates/biome_cli/src/execute/process_file/lint.rs | 1 - crates/biome_cli/src/execute/std_in.rs | 1 - crates/biome_lsp/src/handlers/analysis.rs | 1 - crates/biome_service/src/workspace.rs | 3 --- 5 files changed, 7 deletions(-) diff --git a/crates/biome_cli/src/execute/process_file/assists.rs b/crates/biome_cli/src/execute/process_file/assists.rs index 5251e081be0b..ab6581900a65 100644 --- a/crates/biome_cli/src/execute/process_file/assists.rs +++ b/crates/biome_cli/src/execute/process_file/assists.rs @@ -25,7 +25,6 @@ pub(crate) fn assists_with_guard<'ctx>( .fix_file( FixFileMode::SafeFixes, ctx.execution.as_write_suppressions_mode().is_some(), - None, false, RuleCategoriesBuilder::default().with_action().build(), only.clone(), diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index 5bd77547da7a..e00e8cd7d434 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -36,7 +36,6 @@ pub(crate) fn lint_with_guard<'ctx>( .fix_file( *fix_mode, ctx.execution.as_write_suppressions_mode().is_some(), - None, false, RuleCategoriesBuilder::default() .with_syntax() diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index 5363916755b6..4e7ec8b1029a 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -118,7 +118,6 @@ pub(crate) fn run<'a>( let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, suppress: mode.as_write_suppressions_mode().is_some(), - suppression_reason: None, path: biome_path.clone(), should_format: mode.is_check() && file_features.supports_format(), only: only.clone(), diff --git a/crates/biome_lsp/src/handlers/analysis.rs b/crates/biome_lsp/src/handlers/analysis.rs index 0c9ffdab87c8..fc037e7d8c00 100644 --- a/crates/biome_lsp/src/handlers/analysis.rs +++ b/crates/biome_lsp/src/handlers/analysis.rs @@ -243,7 +243,6 @@ fn fix_all( path: biome_path, fix_file_mode: FixFileMode::SafeFixes, suppress: false, - suppression_reason: None, should_format, only: vec![], skip: vec![], diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index 5b8b4ceb315e..8f72a8556776 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -636,7 +636,6 @@ pub struct FixFileParams { pub path: BiomePath, pub fix_file_mode: FixFileMode, pub suppress: bool, - pub suppression_reason: Option, pub should_format: bool, pub only: Vec, pub skip: Vec, @@ -1063,7 +1062,6 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { &self, fix_file_mode: FixFileMode, suppress: bool, - suppression_reason: Option, should_format: bool, rule_categories: RuleCategories, only: Vec, @@ -1073,7 +1071,6 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { path: self.path.clone(), fix_file_mode, suppress, - suppression_reason, should_format, only, skip, From e6b406d0f591013e6d63725912503814551d1d90 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:06:09 -0600 Subject: [PATCH 28/88] WIP --- crates/biome_service/src/file_handlers/css.rs | 2 +- crates/biome_service/src/file_handlers/graphql.rs | 2 +- crates/biome_service/src/file_handlers/json.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/biome_service/src/file_handlers/css.rs b/crates/biome_service/src/file_handlers/css.rs index 12137c7c95c3..a20ec767623f 100644 --- a/crates/biome_service/src/file_handlers/css.rs +++ b/crates/biome_service/src/file_handlers/css.rs @@ -564,7 +564,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { - println!("No-op'ing in CSS.") + // Not implemented } } } diff --git a/crates/biome_service/src/file_handlers/graphql.rs b/crates/biome_service/src/file_handlers/graphql.rs index f5331a2d8f56..38a9ff741550 100644 --- a/crates/biome_service/src/file_handlers/graphql.rs +++ b/crates/biome_service/src/file_handlers/graphql.rs @@ -530,7 +530,7 @@ pub(crate) fn fix_all(params: FixAllParams) -> Result { - println!("No-op'ing in JSON.") + // Not implemented } } } diff --git a/crates/biome_service/src/file_handlers/json.rs b/crates/biome_service/src/file_handlers/json.rs index 4c1680c96653..1e4ab22cd1ce 100644 --- a/crates/biome_service/src/file_handlers/json.rs +++ b/crates/biome_service/src/file_handlers/json.rs @@ -585,7 +585,7 @@ fn fix_all(params: FixAllParams) -> Result { } } FixFileMode::ApplySuppressions => { - println!("No-op'ing in JSON.") + // Not implemented } } } From cc81046a2f98949fd181e7cf0754fb95eec5ec4d Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:07:24 -0600 Subject: [PATCH 29/88] WIP --- crates/biome_cli/src/commands/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 2cbcab4e10ec..2582a4dd36b8 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -183,6 +183,7 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, + /// Suppress existing diagnostics #[bpaf(long("suppress"))] suppress: bool, From 071d024c1b5634c7a8542eb6f51f1a6a4a0353af Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:08:51 -0600 Subject: [PATCH 30/88] WIP --- crates/biome_cli/src/commands/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 2582a4dd36b8..21ed63fddfcf 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -880,10 +880,10 @@ mod tests { fn safe_and_unsafe_fixes() { let mut console = BufferConsole::default(); - for (apply, apply_unsafe, write, suppress, suppress_reason, fix, unsafe_) in [ - (false, true, false, false, None, false, false), // --apply-unsafe - (false, false, true, false, None, false, true), // --write --unsafe - (false, false, false, false, None, true, true), // --fix --unsafe + for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [ + (false, true, false, false, false, false), // --apply-unsafe + (false, false, true, false, false, true), // --write --unsafe + (false, false, false, false, true, true), // --fix --unsafe ] { assert_eq!( determine_fix_file_mode( From e43e9af48e7defac0a1669862cf993ab975ddc96 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:09:52 -0600 Subject: [PATCH 31/88] WIP --- crates/biome_cli/src/commands/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 21ed63fddfcf..369087cf8b41 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -907,8 +907,8 @@ mod tests { fn no_fix() { let mut console = BufferConsole::default(); - let (apply, apply_unsafe, write, suppress, suppress_reason, fix, unsafe_) = - (false, false, false, false, None, false, false); + let (apply, apply_unsafe, write, suppress, fix, unsafe_) = + (false, false, false, false, false, false); assert_eq!( determine_fix_file_mode( FixFileModeOptions { @@ -916,7 +916,6 @@ mod tests { apply_unsafe, write, suppress, - suppress_reason, fix, unsafe_ }, From 3030687a1b7c80dbfdbc9c6f3c49b383b0a267a0 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:17:40 -0600 Subject: [PATCH 32/88] WIP --- crates/biome_cli/src/commands/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 369087cf8b41..7ddd30569465 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -183,7 +183,7 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, - /// Suppress existing diagnostics + /// Suppress existing diagnostics with a `// biome-ignore` comment #[bpaf(long("suppress"))] suppress: bool, From f19cee6be1291104ed92172e2f9a6248034b1852 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:28:02 -0600 Subject: [PATCH 33/88] Fix codegen. --- .../@biomejs/backend-jsonrpc/src/workspace.ts | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index d10410948d90..927f1d43b286 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -238,7 +238,7 @@ export interface PartialJavascriptConfiguration { /** * A list of global bindings that should be ignored by the analyzers -If defined here, they should not emit diagnostics. +If defined here, they should not emit diagnostics. */ globals?: StringSet; /** @@ -328,7 +328,7 @@ export interface PartialVcsConfiguration { /** * The folder where Biome should check for VCS files. By default, Biome will use the same folder where `biome.json` was found. -If Biome can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, Biome won't use the VCS integration, and a diagnostic will be emitted +If Biome can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, Biome won't use the VCS integration, and a diagnostic will be emitted */ root?: string; /** @@ -407,7 +407,7 @@ export type LineEnding = "lf" | "crlf" | "cr"; /** * Validated value for the `line_width` formatter options -The allowed range of values is 1..=320 +The allowed range of values is 1..=320 */ export type LineWidth = number; /** @@ -551,7 +551,7 @@ export interface PartialJavascriptParser { /** * It enables the experimental and unsafe parsing of parameter decorators -These decorators belong to an old proposal, and they are subject to change. +These decorators belong to an old proposal, and they are subject to change. */ unsafeParameterDecoratorsEnabled?: boolean; } @@ -2441,7 +2441,7 @@ export interface NoDoubleEqualsOptions { /** * If `true`, an exception is made when comparing with `null`, as it's often relied on to check both for `null` or `undefined`. -If `false`, no such exception will be made. +If `false`, no such exception will be made. */ ignoreNull: boolean; } @@ -2449,13 +2449,13 @@ export interface Hook { /** * The "position" of the closure function, starting from zero. -For example, for React's `useEffect()` hook, the closure index is 0. +For example, for React's `useEffect()` hook, the closure index is 0. */ closureIndex?: number; /** * The "position" of the array of dependencies, starting from zero. -For example, for React's `useEffect()` hook, the dependencies index is 1. +For example, for React's `useEffect()` hook, the dependencies index is 1. */ dependenciesIndex?: number; /** @@ -2467,7 +2467,7 @@ For example, for React's `useEffect()` hook, the dependencies index is 1. Set to `true` to mark the identity of the hook's return value as stable, or use a number/an array of numbers to mark the "positions" in the return array as stable. -For example, for React's `useRef()` hook the value would be `true`, while for `useState()` it would be `[1]`. +For example, for React's `useRef()` hook the value would be `true`, while for `useState()` it would be `[1]`. */ stableResult?: StableHookResult; } @@ -2631,13 +2631,13 @@ export type LanguageVariant = "Standard" | "StandardRestricted" | "Jsx"; /** * Enum of the different ECMAScript standard versions. The versions are ordered in increasing order; The newest version comes last. -Defaults to the latest stable ECMAScript standard. +Defaults to the latest stable ECMAScript standard. */ export type LanguageVersion = "ES2022" | "ESNext"; /** * The style of CSS contained in the file. -Currently, Biome only supports plain CSS, and aims to be compatible with the latest Recommendation level standards. +Currently, Biome only supports plain CSS, and aims to be compatible with the latest Recommendation level standards. */ export type CssVariant = "Standard"; /** @@ -3068,7 +3068,7 @@ export type DiagnosticTags = DiagnosticTag[]; /** * Serializable representation of a [Diagnostic](super::Diagnostic) advice -See the [Visitor] trait for additional documentation on all the supported advice types. +See the [Visitor] trait for additional documentation on all the supported advice types. */ export type Advice = | { log: [LogCategory, MarkupBuf] } @@ -3161,7 +3161,7 @@ export interface CodeAction { /** * The category of a code action, this type maps directly to the [CodeActionKind] type in the Language Server Protocol specification -[CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind +[CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind */ export type ActionCategory = | "QuickFix" @@ -3181,7 +3181,7 @@ export interface CodeSuggestion { /** * The sub-category of a refactor code action. -[Check the LSP spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) for more information: +[Check the LSP spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) for more information: */ export type RefactorKind = | "None" @@ -3238,11 +3238,15 @@ export interface FixFileParams { rule_categories: RuleCategories; should_format: boolean; skip: RuleCode[]; + suppress: boolean; } /** * Which fixes should be applied during the analyzing phase */ -export type FixFileMode = "SafeFixes" | "SafeAndUnsafeFixes"; +export type FixFileMode = + | "ApplySuppressions" + | "SafeFixes" + | "SafeAndUnsafeFixes" ; export interface FixFileResult { /** * List of all the code actions applied to the file From 2838190abde8f085a04a4ccf8d6fe69c37860ac9 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:28:31 -0600 Subject: [PATCH 34/88] WIP --- packages/@biomejs/backend-jsonrpc/src/workspace.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index 927f1d43b286..43c9b14f9e4a 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -3246,7 +3246,7 @@ export interface FixFileParams { export type FixFileMode = | "ApplySuppressions" | "SafeFixes" - | "SafeAndUnsafeFixes" ; + | "SafeAndUnsafeFixes"; export interface FixFileResult { /** * List of all the code actions applied to the file From 82fd4614ad17d474e0fbc9a48b4883366af89443 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Tue, 1 Oct 2024 23:30:01 -0600 Subject: [PATCH 35/88] Update crates/biome_cli/src/commands/mod.rs --- crates/biome_cli/src/commands/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 7ddd30569465..97dca992f330 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -183,7 +183,7 @@ pub enum BiomeCommand { #[bpaf(long("write"), switch)] write: bool, - /// Suppress existing diagnostics with a `// biome-ignore` comment + /// Suppress existing diagnostics with a `// biome-ignore` comment (Only implemented for JavaScript) #[bpaf(long("suppress"))] suppress: bool, From 616b5dabb9700dbdbeef3fac0e181e7285aa8a7e Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Wed, 2 Oct 2024 13:01:14 -0600 Subject: [PATCH 36/88] WIP --- crates/biome_cli/src/execute/mod.rs | 7 ++-- .../src/execute/process_file/assists.rs | 2 +- .../src/execute/process_file/lint.rs | 2 +- crates/biome_cli/src/execute/std_in.rs | 2 +- ...d_pass_if_there_are_only_warnings.snap.new | 42 +++++++++++++++++++ .../main_commands_lint/lint_help.snap | 7 +++- ...d_pass_if_there_are_only_warnings.snap.new | 42 +++++++++++++++++++ .../src/file_handlers/javascript.rs | 2 +- 8 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 crates/biome_cli/tests/snapshots/main_commands_check/should_pass_if_there_are_only_warnings.snap.new create mode 100644 crates/biome_cli/tests/snapshots/main_commands_lint/should_pass_if_there_are_only_warnings.snap.new diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index 74028bafe61f..a40536cc0a6f 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -151,6 +151,7 @@ pub enum TraversalMode { skip: Vec, /// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled vcs_targeted: VcsTargeted, + /// Supress existing diagnostics with a `// biome-ignore` comment suppress: bool, }, /// This mode is enabled when running the command `biome ci` @@ -305,14 +306,14 @@ impl Execution { } } - pub(crate) fn as_write_suppressions_mode(&self) -> Option<&bool> { + pub(crate) fn as_write_suppressions_mode(&self) -> bool { match &self.traversal_mode { - TraversalMode::Lint { suppress, .. } => Some(suppress), + TraversalMode::Lint { suppress, .. } => *suppress, TraversalMode::Check { .. } | TraversalMode::Format { .. } | TraversalMode::CI { .. } | TraversalMode::Migrate { .. } - | TraversalMode::Search { .. } => None, + | TraversalMode::Search { .. } => false, } } diff --git a/crates/biome_cli/src/execute/process_file/assists.rs b/crates/biome_cli/src/execute/process_file/assists.rs index ab6581900a65..92c2d44a06f8 100644 --- a/crates/biome_cli/src/execute/process_file/assists.rs +++ b/crates/biome_cli/src/execute/process_file/assists.rs @@ -24,7 +24,7 @@ pub(crate) fn assists_with_guard<'ctx>( .guard() .fix_file( FixFileMode::SafeFixes, - ctx.execution.as_write_suppressions_mode().is_some(), + ctx.execution.as_write_suppressions_mode(), false, RuleCategoriesBuilder::default().with_action().build(), only.clone(), diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index e00e8cd7d434..fde740585293 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -35,7 +35,7 @@ pub(crate) fn lint_with_guard<'ctx>( .guard() .fix_file( *fix_mode, - ctx.execution.as_write_suppressions_mode().is_some(), + ctx.execution.as_write_suppressions_mode(), false, RuleCategoriesBuilder::default() .with_syntax() diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index fe48e519c908..f3be61f09525 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -117,7 +117,7 @@ pub(crate) fn run<'a>( if file_features.supports_lint() { let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, - suppress: mode.as_write_suppressions_mode().is_some(), + suppress: mode.as_write_suppressions_mode(), path: biome_path.clone(), should_format: mode.is_check() && file_features.supports_format(), only: only.clone(), diff --git a/crates/biome_cli/tests/snapshots/main_commands_check/should_pass_if_there_are_only_warnings.snap.new b/crates/biome_cli/tests/snapshots/main_commands_check/should_pass_if_there_are_only_warnings.snap.new new file mode 100644 index 000000000000..f4cb2feccba9 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_commands_check/should_pass_if_there_are_only_warnings.snap.new @@ -0,0 +1,42 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +assertion_line: 423 +expression: content +--- +## `biome.json` + +```json +{ + "linter": { + "rules": { + "recommended": true, + "suspicious": { + "noClassAssign": "warn" + } + } + } +} +``` + +## `file.js` + +```js +class A {} +// biome-ignore lint/suspicious/noClassAssign: +A = 0; + +``` + +# Emitted Messages + +```block +internalError/fs DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! The argument --apply-unsafe is deprecated, it will be removed in the next major release. Use --write --unsafe instead. + + +``` + +```block +Checked 1 file in