diff --git a/.changeset/the_organizeimports_is_now_part_of_biome_assist.md b/.changeset/the_organizeimports_is_now_part_of_biome_assist.md new file mode 100644 index 000000000000..efdc6b259f82 --- /dev/null +++ b/.changeset/the_organizeimports_is_now_part_of_biome_assist.md @@ -0,0 +1,5 @@ +--- +cli: major +--- + +# The `organizeImports` is now part of Biome Assist diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5a9d82cbba0..acd64a7649fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -249,7 +249,7 @@ things you would need to run and check: - `just f` (alias for `just format`), formats Rust and TOML files. - `just l` (alias for `just lint`), run the linter for the whole project. - Code generation. The code generation of the repository is spread in the different parts of the code base. Sometimes is needed and sometime it isn't: - - run `just gen-lint` when you're working on the **linter**; + - run `just gen-analyzer` when you're working on the **linter**; - run `just gen-bindings` in case you worked around the **workspace**. > [!NOTE] diff --git a/Cargo.lock b/Cargo.lock index 5355713b8fa7..6a9445f61819 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1076,11 +1076,11 @@ dependencies = [ "biome_analyze", "biome_console", "biome_diagnostics", - "biome_json_analyze", "biome_json_factory", "biome_json_formatter", "biome_json_parser", "biome_json_syntax", + "biome_project", "biome_rowan", "biome_test_utils", "insta", diff --git a/crates/biome_analyze/CONTRIBUTING.md b/crates/biome_analyze/CONTRIBUTING.md index 7529b5dd7c7c..8d0ae9ed66b7 100644 --- a/crates/biome_analyze/CONTRIBUTING.md +++ b/crates/biome_analyze/CONTRIBUTING.md @@ -1191,7 +1191,7 @@ declare_lint_rule! { For simplicity, use `just` to run all the commands with: ```shell -just gen-lint +just gen-analyzer ``` ### Commiting your work diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index a8d7f7385405..910ef8c72869 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -4,8 +4,7 @@ use crate::commands::{get_files_to_process_with_cli_options, CommandRunner}; use crate::{CliDiagnostic, Execution, TraversalMode}; use biome_configuration::analyzer::assist::PartialAssistConfiguration; use biome_configuration::{ - organize_imports::PartialOrganizeImports, PartialConfiguration, PartialFormatterConfiguration, - PartialLinterConfiguration, + PartialConfiguration, PartialFormatterConfiguration, PartialLinterConfiguration, }; use biome_console::Console; use biome_deserialize::Merge; @@ -22,7 +21,6 @@ pub(crate) struct CheckCommandPayload { pub(crate) stdin_file_path: Option, pub(crate) formatter_enabled: Option, pub(crate) linter_enabled: Option, - pub(crate) organize_imports_enabled: Option, pub(crate) assist_enabled: Option, pub(crate) staged: bool, pub(crate) changed: bool, @@ -73,14 +71,6 @@ impl CommandRunner for CheckCommandPayload { linter.enabled = self.linter_enabled; } - let organize_imports = fs_configuration - .organize_imports - .get_or_insert_with(PartialOrganizeImports::default); - - if self.organize_imports_enabled.is_some() { - organize_imports.enabled = self.organize_imports_enabled; - } - let assist = fs_configuration .assist .get_or_insert_with(PartialAssistConfiguration::default); diff --git a/crates/biome_cli/src/commands/ci.rs b/crates/biome_cli/src/commands/ci.rs index b97c453b3dba..83b426604bbb 100644 --- a/crates/biome_cli/src/commands/ci.rs +++ b/crates/biome_cli/src/commands/ci.rs @@ -3,7 +3,7 @@ use crate::cli_options::CliOptions; use crate::commands::{CommandRunner, LoadEditorConfig}; use crate::{CliDiagnostic, Execution}; use biome_configuration::analyzer::assist::PartialAssistConfiguration; -use biome_configuration::{organize_imports::PartialOrganizeImports, PartialConfiguration}; +use biome_configuration::PartialConfiguration; use biome_configuration::{PartialFormatterConfiguration, PartialLinterConfiguration}; use biome_console::Console; use biome_deserialize::Merge; @@ -15,7 +15,6 @@ use std::ffi::OsString; pub(crate) struct CiCommandPayload { pub(crate) formatter_enabled: Option, pub(crate) linter_enabled: Option, - pub(crate) organize_imports_enabled: Option, pub(crate) assist_enabled: Option, pub(crate) paths: Vec, pub(crate) configuration: Option, @@ -68,14 +67,6 @@ impl CommandRunner for CiCommandPayload { linter.enabled = self.linter_enabled; } - let organize_imports = fs_configuration - .organize_imports - .get_or_insert_with(PartialOrganizeImports::default); - - if self.organize_imports_enabled.is_some() { - organize_imports.enabled = self.organize_imports_enabled; - } - let assist = fs_configuration .assist .get_or_insert_with(PartialAssistConfiguration::default); @@ -130,9 +121,9 @@ impl CommandRunner for CiCommandPayload { fn check_incompatible_arguments(&self) -> Result<(), CliDiagnostic> { if matches!(self.formatter_enabled, Some(false)) && matches!(self.linter_enabled, Some(false)) - && matches!(self.organize_imports_enabled, Some(false)) + && matches!(self.assist_enabled, Some(false)) { - return Err(CliDiagnostic::incompatible_end_configuration("Formatter, linter and organize imports are disabled, can't perform the command. At least one feature needs to be enabled. This is probably and error.")); + return Err(CliDiagnostic::incompatible_end_configuration("Formatter, linter and assist are disabled, can't perform the command. At least one feature needs to be enabled. This is probably and error.")); } if self.since.is_some() && !self.changed { return Err(CliDiagnostic::incompatible_arguments("since", "changed")); diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index d63b442ca45c..54caa2ac35ff 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -128,14 +128,6 @@ pub enum BiomeCommand { /// Allow to enable or disable the linter check. #[bpaf(long("linter-enabled"), argument("true|false"), optional, hide_usage)] linter_enabled: Option, - /// Allow to enable or disable the organize imports. - #[bpaf( - long("organize-imports-enabled"), - argument("true|false"), - optional, - hide_usage - )] - organize_imports_enabled: Option, /// Allow to enable or disable the assist. #[bpaf(long("assist-enabled"), argument("true|false"), optional)] @@ -329,9 +321,6 @@ pub enum BiomeCommand { /// Allow to enable or disable the linter check. #[bpaf(long("linter-enabled"), argument("true|false"), optional)] linter_enabled: Option, - /// Allow to enable or disable the organize imports. - #[bpaf(long("organize-imports-enabled"), argument("true|false"), optional)] - organize_imports_enabled: Option, /// Allow to enable or disable the assist. #[bpaf(long("assist-enabled"), argument("true|false"), optional)] diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs index 1a6ba2ab489d..ed9b630f588c 100644 --- a/crates/biome_cli/src/commands/rage.rs +++ b/crates/biome_cli/src/commands/rage.rs @@ -208,7 +208,7 @@ impl Display for RageConfiguration<'_> { {KeyValuePair("Status", status)} {KeyValuePair("Formatter disabled", markup!({DebugDisplay(configuration.is_formatter_disabled())}))} {KeyValuePair("Linter disabled", markup!({DebugDisplay(configuration.is_linter_disabled())}))} - {KeyValuePair("Organize imports disabled", markup!({DebugDisplay(configuration.is_organize_imports_disabled())}))} + {KeyValuePair("Assist disabled", markup!({DebugDisplay(configuration.is_assist_disabled())}))} {KeyValuePair("VCS disabled", markup!({DebugDisplay(configuration.is_vcs_disabled())}))} ).fmt(fmt)?; @@ -294,13 +294,13 @@ impl Display for RageConfiguration<'_> { let javascript_linter = configuration.get_javascript_linter_configuration(); let json_linter = configuration.get_json_linter_configuration(); let css_linter = configuration.get_css_linter_configuration(); - let graphq_linter = configuration.get_graphql_linter_configuration(); + let graphql_linter = configuration.get_graphql_linter_configuration(); markup! ( {Section("Linter")} {KeyValuePair("JavaScript enabled", markup!({DebugDisplay(javascript_linter.enabled)}))} {KeyValuePair("JSON enabled", markup!({DebugDisplay(json_linter.enabled)}))} {KeyValuePair("CSS enabled", markup!({DebugDisplay(css_linter.enabled)}))} - {KeyValuePair("GraphQL enabled", markup!({DebugDisplay(graphq_linter.enabled)}))} + {KeyValuePair("GraphQL enabled", markup!({DebugDisplay(graphql_linter.enabled)}))} {KeyValuePair("Recommended", markup!({DebugDisplay(linter_configuration.recommended.unwrap_or_default())}))} {RageConfigurationLintRules("Enabled rules", linter_configuration)} ).fmt(fmt)?; diff --git a/crates/biome_cli/src/execute/diagnostics.rs b/crates/biome_cli/src/execute/diagnostics.rs index fc56f6161bf8..1b74c2cd7d8b 100644 --- a/crates/biome_cli/src/execute/diagnostics.rs +++ b/crates/biome_cli/src/execute/diagnostics.rs @@ -18,17 +18,6 @@ pub(crate) struct CIFormatDiffDiagnostic { pub(crate) diff: ContentDiffAdvice, } -#[derive(Debug, Diagnostic)] -#[diagnostic( - category = "organizeImports", - message = "Import statements differs from the output" -)] -pub(crate) struct CIOrganizeImportsDiffDiagnostic { - #[location(resource)] - pub(crate) file_name: String, - #[advice] - pub(crate) diff: ContentDiffAdvice, -} #[derive(Debug, Diagnostic)] #[diagnostic( category = "assist", @@ -54,19 +43,6 @@ pub(crate) struct FormatDiffDiagnostic { pub(crate) diff: ContentDiffAdvice, } -#[derive(Debug, Diagnostic)] -#[diagnostic( - category = "organizeImports", - severity = Error, - message = "Import statements could be sorted:" -)] -pub(crate) struct OrganizeImportsDiffDiagnostic { - #[location(resource)] - pub(crate) file_name: String, - #[advice] - pub(crate) diff: ContentDiffAdvice, -} - #[derive(Debug, Diagnostic)] #[diagnostic( category = "assist", diff --git a/crates/biome_cli/src/execute/migrate/eslint_to_biome.rs b/crates/biome_cli/src/execute/migrate/eslint_to_biome.rs index b387283e9f7b..ad8bbe3e6883 100644 --- a/crates/biome_cli/src/execute/migrate/eslint_to_biome.rs +++ b/crates/biome_cli/src/execute/migrate/eslint_to_biome.rs @@ -346,7 +346,7 @@ mod tests { assert!(biome_config.files.is_none()); assert!(biome_config.overrides.is_none()); assert!(biome_config.formatter.is_none()); - assert!(biome_config.organize_imports.is_none()); + assert!(biome_config.assist.is_none()); let linter = biome_config.linter.unwrap(); assert_eq!(linter.include.unwrap(), ["*.js".into()],); assert_eq!(linter.ignore.unwrap(), ["*.test.js".into()],); @@ -393,7 +393,7 @@ mod tests { assert!(biome_config.files.is_none()); assert!(biome_config.formatter.is_none()); - assert!(biome_config.organize_imports.is_none()); + assert!(biome_config.assist.is_none()); let linter = biome_config.linter.unwrap(); assert!(linter.include.is_none()); assert_eq!( diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index c4f04ca0833b..d0468ccf15f9 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -69,7 +69,6 @@ impl Execution { TraversalMode::Format { .. } => FeaturesBuilder::new().with_formatter().build(), TraversalMode::Lint { .. } => FeaturesBuilder::new().with_linter().build(), TraversalMode::Check { .. } | TraversalMode::CI { .. } => FeaturesBuilder::new() - .with_organize_imports() .with_formatter() .with_linter() .with_assist() diff --git a/crates/biome_cli/src/execute/process_file.rs b/crates/biome_cli/src/execute/process_file.rs index 38541f593ffe..ef363ded673b 100644 --- a/crates/biome_cli/src/execute/process_file.rs +++ b/crates/biome_cli/src/execute/process_file.rs @@ -2,7 +2,6 @@ mod assist; mod check; mod format; mod lint; -mod organize_imports; mod search; pub(crate) mod workspace_file; @@ -73,7 +72,6 @@ impl Message { #[derive(Debug)] pub(crate) enum DiffKind { Format, - OrganizeImports, Assist, } @@ -174,7 +172,7 @@ pub(crate) fn process_file(ctx: &TraversalOptions, biome_path: &BiomePath) -> Fi ) .and( file_features - .support_kind_for(&FeatureKind::OrganizeImports) + .support_kind_for(&FeatureKind::Assist) .and_then(|support_kind| { if support_kind.is_not_enabled() { Some(support_kind) diff --git a/crates/biome_cli/src/execute/process_file/check.rs b/crates/biome_cli/src/execute/process_file/check.rs index 6c6525048647..f37700dc9e8c 100644 --- a/crates/biome_cli/src/execute/process_file/check.rs +++ b/crates/biome_cli/src/execute/process_file/check.rs @@ -1,7 +1,6 @@ use crate::execute::process_file::assist::assist_with_guard; use crate::execute::process_file::format::format_with_guard; use crate::execute::process_file::lint::lint_with_guard; -use crate::execute::process_file::organize_imports::organize_imports_with_guard; use crate::execute::process_file::workspace_file::WorkspaceFile; use crate::execute::process_file::{FileResult, FileStatus, Message, SharedTraversalOptions}; use biome_diagnostics::{category, DiagnosticExt}; @@ -49,27 +48,6 @@ pub(crate) fn check_file<'ctx>( } } - if file_features.supports_organize_imports() { - let organize_imports_result = organize_imports_with_guard(ctx, &mut workspace_file); - match organize_imports_result { - Ok(status) => { - if status.is_changed() { - changed = true - } - if let FileStatus::Message(msg) = status { - if msg.is_failure() { - has_failures = true; - } - ctx.push_message(msg); - } - } - Err(err) => { - ctx.push_message(err); - has_failures = true; - } - } - } - if file_features.supports_assist() { let assist_result = assist_with_guard(ctx, &mut workspace_file); match assist_result { diff --git a/crates/biome_cli/src/execute/process_file/organize_imports.rs b/crates/biome_cli/src/execute/process_file/organize_imports.rs deleted file mode 100644 index 77d53aacc72f..000000000000 --- a/crates/biome_cli/src/execute/process_file/organize_imports.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::ffi::OsStr; - -use crate::execute::diagnostics::ResultExt; -use crate::execute::process_file::workspace_file::WorkspaceFile; -use crate::execute::process_file::{ - DiffKind, FileResult, FileStatus, Message, SharedTraversalOptions, -}; -use biome_diagnostics::category; -use biome_service::file_handlers::{AstroFileHandler, SvelteFileHandler, VueFileHandler}; - -/// Lints a single file and returns a [FileResult] -pub(crate) fn organize_imports_with_guard<'ctx>( - ctx: &'ctx SharedTraversalOptions<'ctx, '_>, - workspace_file: &mut WorkspaceFile, -) -> FileResult { - let _ = - tracing::info_span!("Sort imports for ", path =? workspace_file.path.display()).entered(); - let sorted = workspace_file - .guard() - .organize_imports() - .with_file_path_and_code( - workspace_file.path.display().to_string(), - category!("organizeImports"), - )?; - - let input = workspace_file.input()?; - let mut output = sorted.code; - - match workspace_file.as_extension().map(OsStr::as_encoded_bytes) { - Some(b"astro") => { - if output.is_empty() { - return Ok(FileStatus::Unchanged); - } - output = AstroFileHandler::output(input.as_str(), output.as_str()); - } - Some(b"vue") => { - if output.is_empty() { - return Ok(FileStatus::Unchanged); - } - output = VueFileHandler::output(input.as_str(), output.as_str()); - } - - Some(b"svelte") => { - if output.is_empty() { - return Ok(FileStatus::Unchanged); - } - output = SvelteFileHandler::output(input.as_str(), output.as_str()); - } - _ => {} - } - - if output != input { - if ctx.execution.is_check_apply() || ctx.execution.is_check_apply_unsafe() { - workspace_file.update_file(output)?; - } else { - return Ok(FileStatus::Message(Message::Diff { - file_name: workspace_file.path.display().to_string(), - old: input, - new: output, - diff_kind: DiffKind::OrganizeImports, - })); - } - Ok(FileStatus::Changed) - } else { - Ok(FileStatus::Unchanged) - } -} diff --git a/crates/biome_cli/src/execute/std_in.rs b/crates/biome_cli/src/execute/std_in.rs index 923d2697f8ab..b8b2c2a1ea34 100644 --- a/crates/biome_cli/src/execute/std_in.rs +++ b/crates/biome_cli/src/execute/std_in.rs @@ -10,7 +10,7 @@ use biome_fs::BiomePath; use biome_service::file_handlers::{AstroFileHandler, SvelteFileHandler, VueFileHandler}; use biome_service::workspace::{ ChangeFileParams, DropPatternParams, FeaturesBuilder, FileContent, FixFileParams, - FormatFileParams, OpenFileParams, OrganizeImportsParams, SupportsFeatureParams, + FormatFileParams, OpenFileParams, SupportsFeatureParams, }; use biome_service::WorkspaceError; use std::borrow::Cow; @@ -90,7 +90,7 @@ pub(crate) fn run<'a>( path: biome_path.clone(), features: FeaturesBuilder::new() .with_linter() - .with_organize_imports() + .with_assist() .with_formatter() .build(), })?; @@ -116,7 +116,17 @@ pub(crate) fn run<'a>( }; if let Some(fix_file_mode) = mode.as_fix_file_mode() { - if file_features.supports_lint() { + if file_features.supports_lint() || file_features.supports_assist() { + let mut rule_categories = RuleCategoriesBuilder::default().with_syntax(); + + if file_features.supports_lint() { + rule_categories = rule_categories.with_lint(); + } + + if file_features.supports_assist() { + rule_categories = rule_categories.with_assist(); + } + let fix_file_result = workspace.fix_file(FixFileParams { fix_file_mode: *fix_file_mode, path: biome_path.clone(), @@ -125,10 +135,7 @@ pub(crate) fn run<'a>( skip: skip.clone(), suppression_reason: None, enabled_rules: vec![], - rule_categories: RuleCategoriesBuilder::default() - .with_syntax() - .with_lint() - .build(), + rule_categories: rule_categories.build(), })?; let code = fix_file_result.code; let output = match biome_path.extension().map(|ext| ext.as_encoded_bytes()) { @@ -147,28 +154,6 @@ pub(crate) fn run<'a>( new_content = Cow::Owned(output); } } - - if file_features.supports_organize_imports() && mode.is_check() { - let result = workspace.organize_imports(OrganizeImportsParams { - path: biome_path.clone(), - })?; - let code = result.code; - let output = match biome_path.extension().map(|ext| ext.as_encoded_bytes()) { - Some(b"astro") => AstroFileHandler::output(&new_content, code.as_str()), - Some(b"vue") => VueFileHandler::output(&new_content, code.as_str()), - Some(b"svelte") => SvelteFileHandler::output(&new_content, code.as_str()), - _ => code, - }; - if output != new_content { - version += 1; - workspace.change_file(ChangeFileParams { - content: output.clone(), - path: biome_path.clone(), - version, - })?; - new_content = Cow::Owned(output); - } - } } if file_features.supports_format() && mode.is_check() { diff --git a/crates/biome_cli/src/execute/traverse.rs b/crates/biome_cli/src/execute/traverse.rs index 78dcc3bcf796..f0494fe8fcfe 100644 --- a/crates/biome_cli/src/execute/traverse.rs +++ b/crates/biome_cli/src/execute/traverse.rs @@ -2,9 +2,8 @@ use super::process_file::{process_file, DiffKind, FileStatus, Message}; use super::{Execution, TraversalMode}; use crate::cli_options::CliOptions; use crate::execute::diagnostics::{ - AssistDiffDiagnostic, CIAssistDiffDiagnostic, CIFormatDiffDiagnostic, - CIOrganizeImportsDiffDiagnostic, ContentDiffAdvice, FormatDiffDiagnostic, - OrganizeImportsDiffDiagnostic, PanicDiagnostic, + AssistDiffDiagnostic, CIAssistDiffDiagnostic, CIFormatDiffDiagnostic, ContentDiffAdvice, + FormatDiffDiagnostic, PanicDiagnostic, }; use crate::reporter::TraversalSummary; use crate::{CliDiagnostic, CliSession}; @@ -441,19 +440,6 @@ impl<'ctx> DiagnosticsPrinter<'ctx> { .with_file_source_code(old.clone()), ); } - DiffKind::OrganizeImports => { - let diag = CIOrganizeImportsDiffDiagnostic { - file_name: file_name.clone(), - diff: ContentDiffAdvice { - old: old.clone(), - new: new.clone(), - }, - }; - diagnostics_to_print.push( - diag.with_severity(severity) - .with_file_source_code(old.clone()), - ); - } DiffKind::Assist => { let diag = CIAssistDiffDiagnostic { file_name: file_name.clone(), @@ -483,19 +469,6 @@ impl<'ctx> DiagnosticsPrinter<'ctx> { .with_file_source_code(old.clone()), ) } - DiffKind::OrganizeImports => { - let diag = OrganizeImportsDiffDiagnostic { - file_name: file_name.clone(), - diff: ContentDiffAdvice { - old: old.clone(), - new: new.clone(), - }, - }; - diagnostics_to_print.push( - diag.with_severity(severity) - .with_file_source_code(old.clone()), - ) - } DiffKind::Assist => { let diag = AssistDiffDiagnostic { file_name: file_name.clone(), @@ -652,7 +625,7 @@ impl<'ctx, 'app> TraversalContext for TraversalOptions<'ctx, 'app> { TraversalMode::Check { .. } | TraversalMode::CI { .. } => { file_features.supports_lint() || file_features.supports_format() - || file_features.supports_organize_imports() + || file_features.supports_assist() } TraversalMode::Format { .. } => file_features.supports_format(), TraversalMode::Lint { .. } => file_features.supports_lint(), diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 9d52caa45a11..34ce7ff71bb2 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -86,7 +86,6 @@ impl<'app> CliSession<'app> { paths, stdin_file_path, linter_enabled, - organize_imports_enabled, formatter_enabled, assist_enabled, staged, @@ -103,7 +102,6 @@ impl<'app> CliSession<'app> { paths, stdin_file_path, linter_enabled, - organize_imports_enabled, formatter_enabled, assist_enabled, staged, @@ -160,7 +158,6 @@ impl<'app> CliSession<'app> { BiomeCommand::Ci { linter_enabled, formatter_enabled, - organize_imports_enabled, assist_enabled, configuration, paths, @@ -173,7 +170,6 @@ impl<'app> CliSession<'app> { CiCommandPayload { linter_enabled, formatter_enabled, - organize_imports_enabled, assist_enabled, configuration, paths, diff --git a/crates/biome_cli/src/reporter/summary.rs b/crates/biome_cli/src/reporter/summary.rs index 90aefff0f65d..f2a1670282f3 100644 --- a/crates/biome_cli/src/reporter/summary.rs +++ b/crates/biome_cli/src/reporter/summary.rs @@ -72,6 +72,7 @@ impl<'a> ReporterVisitor for SummaryReporterVisitor<'a> { let category = diagnostic.category(); let severity = &diagnostic.severity(); + if diagnostic.severity() >= diagnostics_payload.diagnostic_level { if diagnostic.tags().is_verbose() { if diagnostics_payload.verbose { @@ -113,8 +114,8 @@ impl<'a> ReporterVisitor for SummaryReporterVisitor<'a> { if execution.is_check() || execution.is_ci() { if let Some(category) = category { - if category.name() == "organizeImports" { - files_to_diagnostics.insert_organize_imports(location); + if category.name() == "assist" { + files_to_diagnostics.insert_assist(location); } } } @@ -130,7 +131,7 @@ impl<'a> ReporterVisitor for SummaryReporterVisitor<'a> { #[derive(Debug, Default)] struct FileToDiagnostics { formats: BTreeSet, - organize_imports: BTreeSet, + assists: BTreeSet, lints: LintsByCategory, parse: BTreeSet, } @@ -145,8 +146,8 @@ impl FileToDiagnostics { self.formats.insert(location.into()); } - fn insert_organize_imports(&mut self, location: &str) { - self.organize_imports.insert(location.into()); + fn insert_assist(&mut self, location: &str) { + self.assists.insert(location.into()); } fn insert_parse(&mut self, location: &str) { @@ -172,10 +173,10 @@ struct SummaryListDiagnostic<'a> { #[derive(Debug, Diagnostic)] #[diagnostic( severity = Information, - category = "reporter/analyzer", - message = "Some analyzer rules were triggered" + category = "reporter/linter", + message = "Some lint rules were triggered" )] -struct SummaryTableDiagnostic<'a> { +struct LintSummaryDiagnostic<'a> { #[advice] tables: &'a LintsByCategory, } @@ -224,7 +225,7 @@ impl Display for FileToDiagnostics { })?; } - if !self.organize_imports.is_empty() { + if !self.assists.is_empty() { let diagnostic = SummaryListDiagnostic { message: MessageAndDescription::from( markup! { @@ -232,8 +233,8 @@ impl Display for FileToDiagnostics { } .to_owned(), ), - list: SummaryListAdvice(&self.organize_imports), - category: category!("reporter/organizeImports"), + list: SummaryListAdvice(&self.assists), + category: category!("reporter/assist"), }; fmt.write_markup(markup! { {PrintDiagnostic::simple(&diagnostic)} @@ -241,7 +242,7 @@ impl Display for FileToDiagnostics { } if !self.lints.0.is_empty() { - let diagnostic = SummaryTableDiagnostic { + let diagnostic = LintSummaryDiagnostic { tables: &self.lints, }; fmt.write_markup(markup! { diff --git a/crates/biome_cli/tests/cases/config_path.rs b/crates/biome_cli/tests/cases/config_path.rs index 885761160823..100bc158b570 100644 --- a/crates/biome_cli/tests/cases/config_path.rs +++ b/crates/biome_cli/tests/cases/config_path.rs @@ -17,7 +17,7 @@ fn set_config_path_to_directory() { fs.insert( config_path.into(), r#"{ - "organizeImports": { + "assist": { "enabled": true }, "linter": { @@ -64,7 +64,7 @@ fn set_config_path_to_file() { fs.insert( config_path.into(), r#"{ - "organizeImports": { + "assist": { "enabled": true }, "linter": { diff --git a/crates/biome_cli/tests/cases/diagnostics.rs b/crates/biome_cli/tests/cases/diagnostics.rs index 5046756f73eb..726bdb245eaf 100644 --- a/crates/biome_cli/tests/cases/diagnostics.rs +++ b/crates/biome_cli/tests/cases/diagnostics.rs @@ -149,7 +149,7 @@ fn diagnostic_level() { "formatter": { "enabled": true }, - "organizeImports": { + "assist": { "enabled": true }, "linter": { @@ -182,7 +182,7 @@ import { FC, memo, useCallback } from "react"; .filter(|m| m.level == LogLevel::Error) .any(|m| { let content = format!("{:?}", m.content); - content.contains("organizeImports") + content.contains("assist") })); assert_cli_snapshot(SnapshotPayload::new( diff --git a/crates/biome_cli/tests/cases/included_files.rs b/crates/biome_cli/tests/cases/included_files.rs index 21aa5fa34268..4f0fcb8459b3 100644 --- a/crates/biome_cli/tests/cases/included_files.rs +++ b/crates/biome_cli/tests/cases/included_files.rs @@ -222,7 +222,7 @@ fn does_not_handle_included_files_if_overridden_by_organize_imports() { r#"{ "formatter": { "enabled": false }, "linter": { "enabled": false }, - "organizeImports": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "assist": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } } "# .as_bytes(), diff --git a/crates/biome_cli/tests/cases/overrides_organize_imports.rs b/crates/biome_cli/tests/cases/overrides_organize_imports.rs index b6b8b538a40a..4def2bb8634f 100644 --- a/crates/biome_cli/tests/cases/overrides_organize_imports.rs +++ b/crates/biome_cli/tests/cases/overrides_organize_imports.rs @@ -21,7 +21,7 @@ fn does_handle_included_file_and_disable_organize_imports() { "files": { "include": ["test.js", "special/**"] }, - "overrides": [{ "include": ["special/**"], "organizeImports": { "enabled": false } }] + "overrides": [{ "include": ["special/**"], "assist": { "enabled": false } }] } "# diff --git a/crates/biome_cli/tests/commands/check.rs b/crates/biome_cli/tests/commands/check.rs index a9cb20a7ccfa..bcdcd893b5f1 100644 --- a/crates/biome_cli/tests/commands/check.rs +++ b/crates/biome_cli/tests/commands/check.rs @@ -1507,7 +1507,7 @@ fn applies_organize_imports() { let mut fs = MemoryFileSystem::default(); let mut console = BufferConsole::default(); - let config = r#"{ "organizeImports": { "enabled": true } }"#; + let config = r#"{ "assist": { "enabled": true } }"#; let file_path = Path::new("biome.json"); fs.insert(file_path.into(), config.as_bytes()); @@ -1545,7 +1545,7 @@ fn applies_organize_imports_bug_4552() { let mut console = BufferConsole::default(); let config = r#"{ - "organizeImports": { + "assist": { "enabled": true, "ignore": ["index.ts"] }, @@ -1649,7 +1649,7 @@ fn dont_applies_organize_imports_for_ignored_file() { let mut fs = MemoryFileSystem::default(); let mut console = BufferConsole::default(); - let rome_json = r#"{ "organizeImports": { "enabled": true, "ignore": ["check.js"] } }"#; + let rome_json = r#"{ "assist": { "enabled": true, "ignore": ["check.js"] } }"#; let config_path = Path::new("biome.json"); fs.insert(config_path.into(), rome_json.as_bytes()); @@ -1711,7 +1711,7 @@ import * as something from "../something"; "--write", "--formatter-enabled=false", "--linter-enabled=false", - "--organize-imports-enabled=true", + "--assist-enabled=true", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -2056,7 +2056,7 @@ fn check_stdin_write_unsafe_successfully() { Args::from( [ "check", - "--organize-imports-enabled=true", + "--assist-enabled=true", "--write", "--unsafe", "--stdin-file-path", @@ -2107,7 +2107,7 @@ fn check_stdin_write_unsafe_only_organize_imports() { Args::from( [ "check", - "--organize-imports-enabled=true", + "--assist-enabled=true", "--linter-enabled=false", "--formatter-enabled=false", "--write", @@ -2157,7 +2157,7 @@ fn check_stdin_returns_text_if_content_is_not_changed() { Args::from( [ "check", - "--organize-imports-enabled=true", + "--assist-enabled=true", "--write", "--unsafe", "--stdin-file-path", @@ -2202,7 +2202,7 @@ fn check_stdin_returns_content_when_not_write() { Args::from( [ "check", - "--organize-imports-enabled=true", + "--assist-enabled=true", "--stdin-file-path", "mock.js", ] @@ -2288,7 +2288,7 @@ fn should_not_enable_all_recommended_rules() { let mut console = BufferConsole::default(); let configuration = r#" { - "organizeImports": { + "assist": { "enabled": false }, "linter": { @@ -2345,7 +2345,7 @@ fn should_not_disable_recommended_rules_for_a_group() { let mut console = BufferConsole::default(); let configuration = r#" { - "organizeImports": { + "assist": { "enabled": false }, "linter": { @@ -2694,7 +2694,7 @@ fn should_show_formatter_diagnostics_for_files_ignored_by_linter() { biome_json.into(), r#"{ "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", - "organizeImports": { + "assist": { "enabled": true }, "linter": { diff --git a/crates/biome_cli/tests/commands/ci.rs b/crates/biome_cli/tests/commands/ci.rs index 0e4c4c6d3e5c..ef9eebc7a90f 100644 --- a/crates/biome_cli/tests/commands/ci.rs +++ b/crates/biome_cli/tests/commands/ci.rs @@ -337,7 +337,7 @@ import * as something from "../something"; Args::from( [ "ci", - "--organize-imports-enabled=false", + "--assist-enabled=false", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -376,7 +376,7 @@ fn ci_errors_for_all_disabled_checks() { "ci", "--linter-enabled=false", "--formatter-enabled=false", - "--organize-imports-enabled=false", + "--assist-enabled=false", file_path.as_os_str().to_str().unwrap(), ] .as_slice(), @@ -687,7 +687,7 @@ fn ci_formatter_linter_organize_imports() { "recommended": true } }, - "organizeImports": { + "assist": { "enabled": true } }"#; diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index 34bd7cc6e52d..a0192c4fc91b 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -3408,7 +3408,7 @@ fn should_format_files_in_folders_ignored_by_linter() { biome_json.into(), r#"{ "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", - "organizeImports": { + "assist": { "enabled": true }, "linter": { diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index 43058b258ac8..35bd5aba0b89 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -2074,7 +2074,7 @@ fn should_not_enable_all_recommended_rules() { let mut console = BufferConsole::default(); let configuration = r#" { - "organizeImports": { + "assist": { "enabled": false }, "linter": { @@ -2131,7 +2131,7 @@ fn should_not_disable_recommended_rules_for_a_group() { let mut console = BufferConsole::default(); let configuration = r#" { - "organizeImports": { + "assist": { "enabled": false }, "linter": { @@ -3953,7 +3953,7 @@ fn linter_shows_the_default_severity_of_rule_on() { "noVar": "on" } } - } + } }"# .as_bytes(), ); diff --git a/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_directory.snap b/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_directory.snap index 85ee23df81e8..28ae507113c5 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_directory.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_directory.snap @@ -1,12 +1,13 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- ## `config/biome.jsonc` ```jsonc { - "organizeImports": { + "assist": { "enabled": true }, "linter": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_file.snap b/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_file.snap index 7bbd9b8327e8..dc0d0048b98e 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_file.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_config_path/set_config_path_to_file.snap @@ -1,12 +1,13 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- ## `config/a.jsonc` ```jsonc { - "organizeImports": { + "assist": { "enabled": true }, "linter": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_diagnostics/diagnostic_level.snap b/crates/biome_cli/tests/snapshots/main_cases_diagnostics/diagnostic_level.snap index 2a0fe73a805f..cb9522211790 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_diagnostics/diagnostic_level.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_diagnostics/diagnostic_level.snap @@ -10,7 +10,7 @@ snapshot_kind: text "formatter": { "enabled": true }, - "organizeImports": { + "assist": { "enabled": true }, "linter": { @@ -41,9 +41,9 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━ # Emitted Messages ```block -src/index.js organizeImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +src/index.js assist ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Import statements could be sorted: + × Not all actions were applied: 1 │ - import·{·graphql,·useFragment,·useMutation·}·from·"react-relay"; 2 │ - import·{·FC,·memo,·useCallback·}·from·"react"; diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/sorts_imports_check.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/sorts_imports_check.snap index 93784494ce34..4107b8cd2ce7 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/sorts_imports_check.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/sorts_imports_check.snap @@ -27,9 +27,9 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━ # Emitted Messages ```block -file.astro organizeImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +file.astro assist ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Import statements could be sorted: + × Not all actions were applied: 1 1 │ --- 2 │ - import·{·getLocale·}·from·"astro:i18n"; diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/sorts_imports_check.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/sorts_imports_check.snap index f90e2058e65b..7c3d565332ff 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/sorts_imports_check.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/sorts_imports_check.snap @@ -27,9 +27,9 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━ # Emitted Messages ```block -file.svelte organizeImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +file.svelte assist ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Import statements could be sorted: + × Not all actions were applied: 1 1 │