diff --git a/crates/biome_cli/src/changed.rs b/crates/biome_cli/src/changed.rs index b3cc63bb91ec..492f92f3a479 100644 --- a/crates/biome_cli/src/changed.rs +++ b/crates/biome_cli/src/changed.rs @@ -1,11 +1,11 @@ use crate::CliDiagnostic; -use biome_configuration::PartialConfiguration; +use biome_configuration::Configuration; use biome_fs::FileSystem; use std::ffi::OsString; pub(crate) fn get_changed_files( fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, since: Option<&str>, ) -> Result, CliDiagnostic> { let default_branch = configuration diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index 7192534e76b3..f544b36a004e 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -2,10 +2,10 @@ use super::{determine_fix_file_mode, FixFileModeOptions, LoadEditorConfig}; use crate::cli_options::CliOptions; 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::{ - PartialConfiguration, PartialFormatterConfiguration, PartialLinterConfiguration, -}; +use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled}; +use biome_configuration::analyzer::LinterEnabled; +use biome_configuration::formatter::FormatterEnabled; +use biome_configuration::{Configuration, FormatterConfiguration, LinterConfiguration}; use biome_console::Console; use biome_deserialize::Merge; use biome_fs::FileSystem; @@ -17,23 +17,23 @@ pub(crate) struct CheckCommandPayload { pub(crate) write: bool, pub(crate) fix: bool, pub(crate) unsafe_: bool, - pub(crate) configuration: Option, + pub(crate) configuration: Option, pub(crate) paths: Vec, pub(crate) stdin_file_path: Option, - pub(crate) formatter_enabled: Option, - pub(crate) linter_enabled: Option, - pub(crate) assist_enabled: Option, + pub(crate) formatter_enabled: Option, + pub(crate) linter_enabled: Option, + pub(crate) assist_enabled: Option, pub(crate) staged: bool, pub(crate) changed: bool, pub(crate) since: Option, } impl LoadEditorConfig for CheckCommandPayload { - fn should_load_editor_config(&self, fs_configuration: &PartialConfiguration) -> bool { + fn should_load_editor_config(&self, fs_configuration: &Configuration) -> bool { self.configuration .as_ref() - .and_then(|c| c.use_editorconfig()) - .unwrap_or(fs_configuration.use_editorconfig().unwrap_or_default()) + .is_some_and(|c| c.use_editorconfig()) + || fs_configuration.use_editorconfig() } } @@ -45,7 +45,7 @@ impl CommandRunner for CheckCommandPayload { loaded_configuration: LoadedConfiguration, fs: &dyn FileSystem, console: &mut dyn Console, - ) -> Result { + ) -> Result { let editorconfig_search_path = loaded_configuration.directory_path.clone(); let LoadedConfiguration { configuration: biome_configuration, @@ -58,7 +58,7 @@ impl CommandRunner for CheckCommandPayload { let formatter = fs_configuration .formatter - .get_or_insert_with(PartialFormatterConfiguration::default); + .get_or_insert_with(FormatterConfiguration::default); if self.formatter_enabled.is_some() { formatter.enabled = self.formatter_enabled; @@ -66,7 +66,7 @@ impl CommandRunner for CheckCommandPayload { let linter = fs_configuration .linter - .get_or_insert_with(PartialLinterConfiguration::default); + .get_or_insert_with(LinterConfiguration::default); if self.linter_enabled.is_some() { linter.enabled = self.linter_enabled; @@ -74,7 +74,7 @@ impl CommandRunner for CheckCommandPayload { let assist = fs_configuration .assist - .get_or_insert_with(PartialAssistConfiguration::default); + .get_or_insert_with(AssistConfiguration::default); if self.assist_enabled.is_some() { assist.enabled = self.assist_enabled; @@ -97,7 +97,7 @@ impl CommandRunner for CheckCommandPayload { fn get_files_to_process( &self, fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, ) -> Result, CliDiagnostic> { let paths = get_files_to_process_with_cli_options( self.since.as_deref(), diff --git a/crates/biome_cli/src/commands/ci.rs b/crates/biome_cli/src/commands/ci.rs index 854b3ba9cf48..b16eb0251845 100644 --- a/crates/biome_cli/src/commands/ci.rs +++ b/crates/biome_cli/src/commands/ci.rs @@ -2,9 +2,10 @@ use crate::changed::get_changed_files; use crate::cli_options::CliOptions; use crate::commands::{CommandRunner, LoadEditorConfig}; use crate::{CliDiagnostic, Execution}; -use biome_configuration::analyzer::assist::PartialAssistConfiguration; -use biome_configuration::PartialConfiguration; -use biome_configuration::{PartialFormatterConfiguration, PartialLinterConfiguration}; +use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled}; +use biome_configuration::analyzer::LinterEnabled; +use biome_configuration::formatter::FormatterEnabled; +use biome_configuration::{Configuration, FormatterConfiguration, LinterConfiguration}; use biome_console::Console; use biome_deserialize::Merge; use biome_fs::FileSystem; @@ -14,21 +15,21 @@ use biome_service::{Workspace, WorkspaceError}; use std::ffi::OsString; pub(crate) struct CiCommandPayload { - pub(crate) formatter_enabled: Option, - pub(crate) linter_enabled: Option, - pub(crate) assist_enabled: Option, + pub(crate) formatter_enabled: Option, + pub(crate) linter_enabled: Option, + pub(crate) assist_enabled: Option, pub(crate) paths: Vec, - pub(crate) configuration: Option, + pub(crate) configuration: Option, pub(crate) changed: bool, pub(crate) since: Option, } impl LoadEditorConfig for CiCommandPayload { - fn should_load_editor_config(&self, fs_configuration: &PartialConfiguration) -> bool { + fn should_load_editor_config(&self, fs_configuration: &Configuration) -> bool { self.configuration .as_ref() - .and_then(|c| c.use_editorconfig()) - .unwrap_or(fs_configuration.use_editorconfig().unwrap_or_default()) + .is_some_and(|c| c.use_editorconfig()) + || fs_configuration.use_editorconfig() } } @@ -40,7 +41,7 @@ impl CommandRunner for CiCommandPayload { loaded_configuration: LoadedConfiguration, fs: &dyn FileSystem, console: &mut dyn Console, - ) -> Result { + ) -> Result { let LoadedConfiguration { configuration: biome_configuration, directory_path: configuration_path, @@ -54,7 +55,7 @@ impl CommandRunner for CiCommandPayload { let formatter = fs_configuration .formatter - .get_or_insert_with(PartialFormatterConfiguration::default); + .get_or_insert_with(FormatterConfiguration::default); if self.formatter_enabled.is_some() { formatter.enabled = self.formatter_enabled; @@ -62,7 +63,7 @@ impl CommandRunner for CiCommandPayload { let linter = fs_configuration .linter - .get_or_insert_with(PartialLinterConfiguration::default); + .get_or_insert_with(LinterConfiguration::default); if self.linter_enabled.is_some() { linter.enabled = self.linter_enabled; @@ -70,7 +71,7 @@ impl CommandRunner for CiCommandPayload { let assist = fs_configuration .assist - .get_or_insert_with(PartialAssistConfiguration::default); + .get_or_insert_with(AssistConfiguration::default); if self.assist_enabled.is_some() { assist.enabled = self.assist_enabled; @@ -93,7 +94,7 @@ impl CommandRunner for CiCommandPayload { fn get_files_to_process( &self, fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, ) -> Result, CliDiagnostic> { if self.changed { get_changed_files(fs, configuration, self.since.as_deref()) @@ -121,9 +122,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.assist_enabled, Some(false)) + if self.formatter_enabled.is_some_and(|v| !v.value()) + && self.linter_enabled.is_some_and(|v| !v.value()) + && self.assist_enabled.is_some_and(|v| !v.value()) { 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.")); } diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 5ec5469a1bcd..031b9f99b018 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -1,12 +1,12 @@ use crate::cli_options::CliOptions; use crate::commands::{get_files_to_process_with_cli_options, CommandRunner, LoadEditorConfig}; use crate::{CliDiagnostic, Execution, TraversalMode}; -use biome_configuration::vcs::PartialVcsConfiguration; -use biome_configuration::{ - PartialConfiguration, PartialCssFormatter, PartialFilesConfiguration, - PartialFormatterConfiguration, PartialGraphqlFormatter, PartialJavascriptFormatter, - PartialJsonFormatter, -}; +use biome_configuration::css::CssFormatterConfiguration; +use biome_configuration::graphql::GraphqlFormatterConfiguration; +use biome_configuration::javascript::JsFormatterConfiguration; +use biome_configuration::json::JsonFormatterConfiguration; +use biome_configuration::vcs::VcsConfiguration; +use biome_configuration::{Configuration, FilesConfiguration, FormatterConfiguration}; use biome_console::Console; use biome_deserialize::Merge; use biome_fs::FileSystem; @@ -16,13 +16,13 @@ use biome_service::{Workspace, WorkspaceError}; use std::ffi::OsString; pub(crate) struct FormatCommandPayload { - pub(crate) javascript_formatter: Option, - pub(crate) json_formatter: Option, - pub(crate) css_formatter: Option, - pub(crate) graphql_formatter: Option, - pub(crate) formatter_configuration: Option, - pub(crate) vcs_configuration: Option, - pub(crate) files_configuration: Option, + pub(crate) javascript_formatter: Option, + pub(crate) json_formatter: Option, + pub(crate) css_formatter: Option, + pub(crate) graphql_formatter: Option, + pub(crate) formatter_configuration: Option, + pub(crate) vcs_configuration: Option, + pub(crate) files_configuration: Option, pub(crate) stdin_file_path: Option, pub(crate) write: bool, pub(crate) fix: bool, @@ -33,11 +33,11 @@ pub(crate) struct FormatCommandPayload { } impl LoadEditorConfig for FormatCommandPayload { - fn should_load_editor_config(&self, fs_configuration: &PartialConfiguration) -> bool { + fn should_load_editor_config(&self, fs_configuration: &Configuration) -> bool { self.formatter_configuration .as_ref() - .and_then(|c| c.use_editorconfig) - .unwrap_or(fs_configuration.use_editorconfig().unwrap_or_default()) + .is_some_and(|c| c.use_editorconfig_resolved()) + || fs_configuration.use_editorconfig() } } @@ -49,7 +49,7 @@ impl CommandRunner for FormatCommandPayload { loaded_configuration: LoadedConfiguration, fs: &dyn FileSystem, console: &mut dyn Console, - ) -> Result { + ) -> Result { let LoadedConfiguration { configuration: biome_configuration, directory_path: configuration_path, @@ -66,14 +66,14 @@ impl CommandRunner for FormatCommandPayload { if !configuration .formatter .as_ref() - .is_some_and(PartialFormatterConfiguration::is_disabled) + .is_some_and(|f| !f.is_enabled()) { let formatter = configuration.formatter.get_or_insert_with(Default::default); if let Some(formatter_configuration) = self.formatter_configuration.clone() { formatter.merge_with(formatter_configuration); } - formatter.enabled = Some(true); + formatter.enabled = Some(true.into()); } if self.css_formatter.is_some() { let css = configuration.css.get_or_insert_with(Default::default); @@ -108,7 +108,7 @@ impl CommandRunner for FormatCommandPayload { fn get_files_to_process( &self, fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, ) -> Result, CliDiagnostic> { let paths = get_files_to_process_with_cli_options( self.since.as_deref(), diff --git a/crates/biome_cli/src/commands/init.rs b/crates/biome_cli/src/commands/init.rs index bd42caad9161..619bda7d8419 100644 --- a/crates/biome_cli/src/commands/init.rs +++ b/crates/biome_cli/src/commands/init.rs @@ -1,12 +1,12 @@ use crate::{CliDiagnostic, CliSession}; -use biome_configuration::PartialConfiguration; +use biome_configuration::Configuration; use biome_console::{markup, ConsoleExt}; use biome_fs::ConfigName; use biome_service::configuration::create_config; pub(crate) fn init(session: CliSession, emit_jsonc: bool) -> Result<(), CliDiagnostic> { let fs = session.app.workspace.fs(); - create_config(fs, PartialConfiguration::init(), emit_jsonc)?; + create_config(fs, Configuration::init(), emit_jsonc)?; let file_created = if emit_jsonc { ConfigName::biome_jsonc() } else { diff --git a/crates/biome_cli/src/commands/lint.rs b/crates/biome_cli/src/commands/lint.rs index f3fbc73a4f3e..115275f4f554 100644 --- a/crates/biome_cli/src/commands/lint.rs +++ b/crates/biome_cli/src/commands/lint.rs @@ -3,14 +3,12 @@ use crate::cli_options::CliOptions; use crate::commands::{get_files_to_process_with_cli_options, CommandRunner}; use crate::{CliDiagnostic, Execution, TraversalMode}; use biome_configuration::analyzer::RuleSelector; -use biome_configuration::css::PartialCssLinter; -use biome_configuration::javascript::PartialJavascriptLinter; -use biome_configuration::json::PartialJsonLinter; -use biome_configuration::vcs::PartialVcsConfiguration; -use biome_configuration::{ - PartialConfiguration, PartialFilesConfiguration, PartialGraphqlLinter, - PartialLinterConfiguration, -}; +use biome_configuration::css::CssLinterConfiguration; +use biome_configuration::graphql::GraphqlLinterConfiguration; +use biome_configuration::javascript::JsLinterConfiguration; +use biome_configuration::json::JsonLinterConfiguration; +use biome_configuration::vcs::VcsConfiguration; +use biome_configuration::{Configuration, FilesConfiguration, LinterConfiguration}; use biome_console::Console; use biome_deserialize::Merge; use biome_fs::FileSystem; @@ -25,9 +23,9 @@ pub(crate) struct LintCommandPayload { pub(crate) unsafe_: bool, pub(crate) suppress: bool, pub(crate) suppression_reason: Option, - pub(crate) linter_configuration: Option, - pub(crate) vcs_configuration: Option, - pub(crate) files_configuration: Option, + pub(crate) linter_configuration: Option, + pub(crate) vcs_configuration: Option, + pub(crate) files_configuration: Option, pub(crate) paths: Vec, pub(crate) only: Vec, pub(crate) skip: Vec, @@ -35,10 +33,10 @@ pub(crate) struct LintCommandPayload { pub(crate) staged: bool, pub(crate) changed: bool, pub(crate) since: Option, - pub(crate) javascript_linter: Option, - pub(crate) json_linter: Option, - pub(crate) css_linter: Option, - pub(crate) graphql_linter: Option, + pub(crate) javascript_linter: Option, + pub(crate) json_linter: Option, + pub(crate) css_linter: Option, + pub(crate) graphql_linter: Option, } impl CommandRunner for LintCommandPayload { @@ -49,17 +47,17 @@ impl CommandRunner for LintCommandPayload { loaded_configuration: LoadedConfiguration, _fs: &dyn FileSystem, _console: &mut dyn Console, - ) -> Result { + ) -> Result { let LoadedConfiguration { configuration: mut fs_configuration, .. } = loaded_configuration; - fs_configuration.merge_with(PartialConfiguration { + fs_configuration.merge_with(Configuration { linter: if fs_configuration .linter .as_ref() - .is_some_and(PartialLinterConfiguration::is_disabled) + .is_some_and(LinterConfiguration::is_enabled) { None } else { @@ -102,7 +100,7 @@ impl CommandRunner for LintCommandPayload { fn get_files_to_process( &self, fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, ) -> Result, CliDiagnostic> { let paths = get_files_to_process_with_cli_options( self.since.as_deref(), diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index de78fd624330..971facc13eea 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -5,7 +5,7 @@ use crate::cli_options::CliOptions; use crate::diagnostics::MigrationDiagnostic; use crate::execute::{Execution, TraversalMode}; use crate::CliDiagnostic; -use biome_configuration::PartialConfiguration; +use biome_configuration::Configuration; use biome_console::{markup, Console, ConsoleExt}; use biome_fs::FileSystem; use biome_service::configuration::LoadedConfiguration; @@ -30,7 +30,7 @@ impl CommandRunner for MigrateCommandPayload { loaded_configuration: LoadedConfiguration, _fs: &dyn FileSystem, _console: &mut dyn Console, - ) -> Result { + ) -> Result { self.configuration_file_path = loaded_configuration.file_path; self.configuration_directory_path = loaded_configuration.directory_path; Ok(loaded_configuration.configuration) @@ -39,7 +39,7 @@ impl CommandRunner for MigrateCommandPayload { fn get_files_to_process( &self, _fs: &dyn FileSystem, - _configuration: &PartialConfiguration, + _configuration: &Configuration, ) -> Result, CliDiagnostic> { Ok(vec![]) } diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 71491edeaf65..2de1dea1b338 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -5,27 +5,29 @@ use crate::logging::LoggingKind; use crate::{ execute_mode, setup_cli_subscriber, CliDiagnostic, CliSession, Execution, LoggingLevel, VERSION, }; -use biome_configuration::analyzer::RuleSelector; -use biome_configuration::css::PartialCssLinter; -use biome_configuration::javascript::PartialJavascriptLinter; -use biome_configuration::json::PartialJsonLinter; +use biome_configuration::analyzer::assist::AssistEnabled; +use biome_configuration::analyzer::{LinterEnabled, RuleSelector}; +use biome_configuration::css::{CssFormatterConfiguration, CssLinterConfiguration}; +use biome_configuration::formatter::FormatterEnabled; +use biome_configuration::graphql::{GraphqlFormatterConfiguration, GraphqlLinterConfiguration}; +use biome_configuration::javascript::{JsFormatterConfiguration, JsLinterConfiguration}; +use biome_configuration::json::{JsonFormatterConfiguration, JsonLinterConfiguration}; +use biome_configuration::vcs::VcsConfiguration; use biome_configuration::{ - css::partial_css_formatter, css::partial_css_linter, graphql::partial_graphql_formatter, - graphql::partial_graphql_linter, javascript::partial_javascript_formatter, - javascript::partial_javascript_linter, json::partial_json_formatter, json::partial_json_linter, - partial_configuration, partial_files_configuration, partial_formatter_configuration, - partial_linter_configuration, vcs::partial_vcs_configuration, vcs::PartialVcsConfiguration, - PartialCssFormatter, PartialFilesConfiguration, PartialFormatterConfiguration, - PartialGraphqlFormatter, PartialGraphqlLinter, PartialJavascriptFormatter, - PartialJsonFormatter, PartialLinterConfiguration, + configuration, css::css_formatter_configuration, css::css_linter_configuration, + files_configuration, formatter_configuration, graphql::graphql_formatter_configuration, + graphql::graphql_linter_configuration, javascript::js_formatter_configuration, + javascript::js_linter_configuration, json::json_formatter_configuration, + json::json_linter_configuration, linter_configuration, vcs::vcs_configuration, + FilesConfiguration, FormatterConfiguration, LinterConfiguration, }; -use biome_configuration::{BiomeDiagnostic, PartialConfiguration}; +use biome_configuration::{BiomeDiagnostic, Configuration}; use biome_console::{markup, Console, ConsoleExt}; use biome_diagnostics::PrintDiagnostic; use biome_fs::{BiomePath, FileSystem}; use biome_grit_patterns::GritTargetLanguage; use biome_service::configuration::{ - load_configuration, load_editorconfig, LoadedConfiguration, PartialConfigurationExt, + load_configuration, load_editorconfig, ConfigurationExt, LoadedConfiguration, }; use biome_service::documentation::Doc; use biome_service::projects::ProjectKey; @@ -127,17 +129,17 @@ pub enum BiomeCommand { optional, hide_usage )] - formatter_enabled: Option, + formatter_enabled: Option, /// Allow to enable or disable the linter check. #[bpaf(long("linter-enabled"), argument("true|false"), optional, hide_usage)] - linter_enabled: Option, + linter_enabled: Option, /// Allow to enable or disable the assist. #[bpaf(long("assist-enabled"), argument("true|false"), optional)] - assist_enabled: Option, + assist_enabled: Option, - #[bpaf(external(partial_configuration), hide_usage, optional)] - configuration: Option, + #[bpaf(external(configuration), hide_usage, optional)] + configuration: Option, #[bpaf(external, hide_usage)] cli_options: CliOptions, /// Use this option when you want to format code piped from `stdin`, and print the output to `stdout`. @@ -190,26 +192,26 @@ pub enum BiomeCommand { #[bpaf(long("reason"), argument("STRING"))] suppression_reason: Option, - #[bpaf(external(partial_linter_configuration), hide_usage, optional)] - linter_configuration: Option, + #[bpaf(external(linter_configuration), hide_usage, optional)] + linter_configuration: Option, - #[bpaf(external(partial_vcs_configuration), optional, hide_usage)] - vcs_configuration: Option, + #[bpaf(external(vcs_configuration), optional, hide_usage)] + vcs_configuration: Option, - #[bpaf(external(partial_files_configuration), optional, hide_usage)] - files_configuration: Option, + #[bpaf(external(files_configuration), optional, hide_usage)] + files_configuration: Option, - #[bpaf(external(partial_javascript_linter), optional, hide_usage)] - javascript_linter: Option, + #[bpaf(external(js_linter_configuration), optional, hide_usage)] + javascript_linter: Option, - #[bpaf(external(partial_json_linter), optional, hide_usage)] - json_linter: Option, + #[bpaf(external(json_linter_configuration), optional, hide_usage)] + json_linter: Option, - #[bpaf(external(partial_css_linter), optional, hide_usage, hide)] - css_linter: Option, + #[bpaf(external(css_linter_configuration), optional, hide_usage, hide)] + css_linter: Option, - #[bpaf(external(partial_graphql_linter), optional, hide_usage, hide)] - graphql_linter: Option, + #[bpaf(external(graphql_linter_configuration), optional, hide_usage, hide)] + graphql_linter: Option, #[bpaf(external, hide_usage)] cli_options: CliOptions, @@ -255,26 +257,26 @@ pub enum BiomeCommand { /// Run the formatter on a set of files. #[bpaf(command)] Format { - #[bpaf(external(partial_formatter_configuration), optional, hide_usage)] - formatter_configuration: Option, + #[bpaf(external(formatter_configuration), optional, hide_usage)] + formatter_configuration: Option, - #[bpaf(external(partial_javascript_formatter), optional, hide_usage)] - javascript_formatter: Option, + #[bpaf(external(js_formatter_configuration), optional, hide_usage)] + javascript_formatter: Option, - #[bpaf(external(partial_json_formatter), optional, hide_usage)] - json_formatter: Option, + #[bpaf(external(json_formatter_configuration), optional, hide_usage)] + json_formatter: Option, - #[bpaf(external(partial_css_formatter), optional, hide_usage, hide)] - css_formatter: Option, + #[bpaf(external(css_formatter_configuration), optional, hide_usage, hide)] + css_formatter: Option, - #[bpaf(external(partial_graphql_formatter), optional, hide_usage, hide)] - graphql_formatter: Option, + #[bpaf(external(graphql_formatter_configuration), optional, hide_usage, hide)] + graphql_formatter: Option, - #[bpaf(external(partial_vcs_configuration), optional, hide_usage)] - vcs_configuration: Option, + #[bpaf(external(vcs_configuration), optional, hide_usage)] + vcs_configuration: Option, - #[bpaf(external(partial_files_configuration), optional, hide_usage)] - files_configuration: Option, + #[bpaf(external(files_configuration), optional, hide_usage)] + files_configuration: Option, /// Use this option when you want to format code piped from `stdin`, and print the output to `stdout`. /// /// The file doesn't need to exist on disk, what matters is the extension of the file. Based on the extension, Biome knows how to format the code. @@ -320,17 +322,17 @@ pub enum BiomeCommand { Ci { /// Allow to enable or disable the formatter check. #[bpaf(long("formatter-enabled"), argument("true|false"), optional)] - formatter_enabled: Option, + formatter_enabled: Option, /// Allow to enable or disable the linter check. #[bpaf(long("linter-enabled"), argument("true|false"), optional)] - linter_enabled: Option, + linter_enabled: Option, /// Allow to enable or disable the assist. #[bpaf(long("assist-enabled"), argument("true|false"), optional)] - assist_enabled: Option, + assist_enabled: Option, - #[bpaf(external(partial_configuration), hide_usage, optional)] - configuration: Option, + #[bpaf(external(configuration), hide_usage, optional)] + configuration: Option, #[bpaf(external, hide_usage)] cli_options: CliOptions, @@ -420,11 +422,11 @@ pub enum BiomeCommand { #[bpaf(external, hide_usage)] cli_options: CliOptions, - #[bpaf(external(partial_files_configuration), optional, hide_usage)] - files_configuration: Option, + #[bpaf(external(files_configuration), optional, hide_usage)] + files_configuration: Option, - #[bpaf(external(partial_vcs_configuration), optional, hide_usage)] - vcs_configuration: Option, + #[bpaf(external(vcs_configuration), optional, hide_usage)] + vcs_configuration: Option, /// Use this option when you want to search through code piped from /// `stdin`, and print the output to `stdout`. @@ -606,7 +608,7 @@ impl BiomeCommand { } } -/// It accepts a [LoadedPartialConfiguration] and it prints the diagnostics emitted during parsing and deserialization. +/// It accepts a [LoadedConfiguration] and it prints the diagnostics emitted during parsing and deserialization. /// /// If it contains [errors](Severity::Error) or higher, it returns an error. pub(crate) fn validate_configuration_diagnostics( @@ -640,7 +642,7 @@ fn get_files_to_process_with_cli_options( changed: bool, staged: bool, fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, ) -> Result>, CliDiagnostic> { if since.is_some() { if !changed { @@ -849,13 +851,13 @@ pub(crate) trait CommandRunner: Sized { loaded_configuration: LoadedConfiguration, fs: &dyn FileSystem, console: &mut dyn Console, - ) -> Result; + ) -> Result; /// It returns the paths that need to be handled/traversed. fn get_files_to_process( &self, fs: &dyn FileSystem, - configuration: &PartialConfiguration, + configuration: &Configuration, ) -> Result, CliDiagnostic>; /// It returns the file path to use in `stdin` mode. @@ -890,16 +892,16 @@ pub(crate) trait CommandRunner: Sized { pub trait LoadEditorConfig: CommandRunner { /// Whether this command should load the `.editorconfig` file. - fn should_load_editor_config(&self, fs_configuration: &PartialConfiguration) -> bool; + fn should_load_editor_config(&self, fs_configuration: &Configuration) -> bool; - /// It loads the `.editorconfig` from the file system, parses it and deserialize it into a [PartialConfiguration] + /// It loads the `.editorconfig` from the file system, parses it and deserialize it into a [Configuration] fn load_editor_config( &self, configuration_path: Option, - fs_configuration: &PartialConfiguration, + fs_configuration: &Configuration, fs: &dyn FileSystem, console: &mut dyn Console, - ) -> Result { + ) -> Result { Ok(if self.should_load_editor_config(fs_configuration) { let (editorconfig, editorconfig_diagnostics) = { let search_path = configuration_path diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs index 2cc258c0694e..d21cdf730137 100644 --- a/crates/biome_cli/src/commands/rage.rs +++ b/crates/biome_cli/src/commands/rage.rs @@ -1,3 +1,6 @@ +use crate::commands::daemon::read_most_recent_log_file; +use crate::service::enumerate_pipes; +use crate::{service, CliDiagnostic, CliSession, VERSION}; use biome_configuration::{ConfigurationPathHint, Rules}; use biome_console::fmt::{Display, Formatter}; use biome_console::{ @@ -9,6 +12,7 @@ use biome_diagnostics::{termcolor, PrintDescription}; use biome_flags::biome_env; use biome_fs::{FileSystem, OsFileSystem}; use biome_service::configuration::{load_configuration, LoadedConfiguration}; +use biome_service::settings::Settings; use biome_service::workspace::{client, RageEntry, RageParams}; use biome_service::Workspace; use camino::Utf8PathBuf; @@ -16,10 +20,6 @@ use std::{env, io, ops::Deref}; use terminal_size::terminal_size; use tokio::runtime::Runtime; -use crate::commands::daemon::read_most_recent_log_file; -use crate::service::enumerate_pipes; -use crate::{service, CliDiagnostic, CliSession, VERSION}; - /// Handler for the `rage` command pub(crate) fn rage( session: CliSession, @@ -204,13 +204,19 @@ impl Display for RageConfiguration<'_> { match load_configuration(self.fs, ConfigurationPathHint::default()) { Ok(loaded_configuration) => { if loaded_configuration.directory_path.is_none() { - KeyValuePair("Status", markup!("unset")).fmt(fmt)?; + KeyValuePair("Status", markup!("Not set")).fmt(fmt)?; } else { let LoadedConfiguration { configuration, diagnostics, .. } = loaded_configuration; + let vcs_enabled = configuration.is_vcs_enabled(); + let mut settings = Settings::default(); + settings + .merge_with_configuration(configuration.clone(), None, None, &[]) + .unwrap(); + let status = if !diagnostics.is_empty() { for diagnostic in diagnostics { (markup! { @@ -227,53 +233,53 @@ impl Display for RageConfiguration<'_> { markup! ( {KeyValuePair("Status", status)} - {KeyValuePair("Formatter disabled", markup!({DebugDisplay(configuration.is_formatter_disabled())}))} - {KeyValuePair("Linter disabled", markup!({DebugDisplay(configuration.is_linter_disabled())}))} - {KeyValuePair("Assist disabled", markup!({DebugDisplay(configuration.is_assist_disabled())}))} - {KeyValuePair("VCS disabled", markup!({DebugDisplay(configuration.is_vcs_disabled())}))} + {KeyValuePair("Formatter enabled", markup!({DebugDisplay(settings.is_formatter_enabled())}))} + {KeyValuePair("Linter enabled", markup!({DebugDisplay(settings.is_linter_enabled())}))} + {KeyValuePair("Assist enabled", markup!({DebugDisplay(settings.is_assist_enabled())}))} + {KeyValuePair("VCS enabled", markup!({DebugDisplay(vcs_enabled)}))} ).fmt(fmt)?; // Print formatter configuration if --formatter option is true if self.formatter { let formatter_configuration = configuration.get_formatter_configuration(); - let ignore = formatter_configuration - .ignore - .iter() - .map(|s| s.to_string()) - .collect::>() - .join(", "); - let include = formatter_configuration - .include - .iter() - .map(|s| s.to_string()) - .collect::>() - .join(", "); + let ignore = formatter_configuration.ignore.map(|list| { + list.iter() + .map(|s| s.to_string()) + .collect::>() + .join(", ") + }); + let include = formatter_configuration.include.map(|list| { + list.iter() + .map(|s| s.to_string()) + .collect::>() + .join(", ") + }); markup! ( {Section("Formatter")} - {KeyValuePair("Format with errors", markup!({DebugDisplay(configuration.get_formatter_configuration().format_with_errors)}))} - {KeyValuePair("Indent style", markup!({DebugDisplay(formatter_configuration.indent_style)}))} - {KeyValuePair("Indent width", markup!({DebugDisplay(formatter_configuration.indent_width)}))} - {KeyValuePair("Line ending", markup!({DebugDisplay(formatter_configuration.line_ending)}))} - {KeyValuePair("Line width", markup!({DebugDisplay(formatter_configuration.line_width.value())}))} - {KeyValuePair("Attribute position", markup!({DebugDisplay(formatter_configuration.attribute_position)}))} - {KeyValuePair("Bracket spacing", markup!({DebugDisplay(formatter_configuration.bracket_spacing)}))} - {KeyValuePair("Ignore", markup!({DebugDisplay(ignore)}))} - {KeyValuePair("Include", markup!({DebugDisplay(include)}))} + {KeyValuePair("Format with errors", markup!({DisplayOption(configuration.get_formatter_configuration().format_with_errors)}))} + {KeyValuePair("Indent style", markup!({DisplayOption(formatter_configuration.indent_style)}))} + {KeyValuePair("Indent width", markup!({DisplayOption(formatter_configuration.indent_width)}))} + {KeyValuePair("Line ending", markup!({DisplayOption(formatter_configuration.line_ending)}))} + {KeyValuePair("Line width", markup!({DisplayOption(formatter_configuration.line_width)}))} + {KeyValuePair("Attribute position", markup!({DisplayOption(formatter_configuration.attribute_position)}))} + {KeyValuePair("Bracket spacing", markup!({DisplayOption(formatter_configuration.bracket_spacing)}))} + {KeyValuePair("Ignore", markup!({DisplayOption(ignore)}))} + {KeyValuePair("Include", markup!({DisplayOption(include)}))} ).fmt(fmt)?; let javascript_formatter_configuration = configuration.get_javascript_formatter_configuration(); markup! ( {Section("JavaScript Formatter")} - {KeyValuePair("Enabled", markup!({DebugDisplay(javascript_formatter_configuration.enabled)}))} - {KeyValuePair("JSX quote style", markup!({DebugDisplay(javascript_formatter_configuration.jsx_quote_style)}))} - {KeyValuePair("Quote properties", markup!({DebugDisplay(javascript_formatter_configuration.quote_properties)}))} - {KeyValuePair("Trailing commas", markup!({DebugDisplay(javascript_formatter_configuration.trailing_commas)}))} - {KeyValuePair("Semicolons", markup!({DebugDisplay(javascript_formatter_configuration.semicolons)}))} - {KeyValuePair("Arrow parentheses", markup!({DebugDisplay(javascript_formatter_configuration.arrow_parentheses)}))} + {KeyValuePair("Enabled", markup!({DisplayOption(javascript_formatter_configuration.enabled)}))} + {KeyValuePair("JSX quote style", markup!({DisplayOption(javascript_formatter_configuration.jsx_quote_style)}))} + {KeyValuePair("Quote properties", markup!({DisplayOption(javascript_formatter_configuration.quote_properties)}))} + {KeyValuePair("Trailing commas", markup!({DisplayOption(javascript_formatter_configuration.trailing_commas)}))} + {KeyValuePair("Semicolons", markup!({DisplayOption(javascript_formatter_configuration.semicolons)}))} + {KeyValuePair("Arrow parentheses", markup!({DisplayOption(javascript_formatter_configuration.arrow_parentheses)}))} {KeyValuePair("Bracket spacing", markup!({DisplayOption(javascript_formatter_configuration.bracket_spacing)}))} {KeyValuePair("Bracket same line", markup!({DisplayOption(javascript_formatter_configuration.bracket_same_line)}))} - {KeyValuePair("Quote style", markup!({DebugDisplay(javascript_formatter_configuration.quote_style)}))} + {KeyValuePair("Quote style", markup!({DisplayOption(javascript_formatter_configuration.quote_style)}))} {KeyValuePair("Indent style", markup!({DisplayOption(javascript_formatter_configuration.indent_style)}))} {KeyValuePair("Indent width", markup!({DisplayOption(javascript_formatter_configuration.indent_width)}))} {KeyValuePair("Line ending", markup!({DisplayOption(javascript_formatter_configuration.line_ending)}))} @@ -286,7 +292,7 @@ impl Display for RageConfiguration<'_> { configuration.get_json_formatter_configuration(); markup! ( {Section("JSON Formatter")} - {KeyValuePair("Enabled", markup!({DebugDisplay(json_formatter_configuration.enabled)}))} + {KeyValuePair("Enabled", markup!({DisplayOption(json_formatter_configuration.enabled)}))} {KeyValuePair("Indent style", markup!({DisplayOption(json_formatter_configuration.indent_style)}))} {KeyValuePair("Indent width", markup!({DisplayOption(json_formatter_configuration.indent_width)}))} {KeyValuePair("Line ending", markup!({DisplayOption(json_formatter_configuration.line_ending)}))} @@ -299,12 +305,12 @@ impl Display for RageConfiguration<'_> { configuration.get_css_formatter_configuration(); markup! ( {Section("CSS Formatter")} - {KeyValuePair("Enabled", markup!({DebugDisplay(css_formatter_configuration.enabled)}))} + {KeyValuePair("Enabled", markup!({DisplayOption(css_formatter_configuration.enabled)}))} {KeyValuePair("Indent style", markup!({DisplayOption(css_formatter_configuration.indent_style)}))} {KeyValuePair("Indent width", markup!({DisplayOption(css_formatter_configuration.indent_width)}))} {KeyValuePair("Line ending", markup!({DisplayOption(css_formatter_configuration.line_ending)}))} {KeyValuePair("Line width", markup!({DisplayOption(css_formatter_configuration.line_width)}))} - {KeyValuePair("Quote style", markup!({DebugDisplay(css_formatter_configuration.quote_style)}))} + {KeyValuePair("Quote style", markup!({DisplayOption(css_formatter_configuration.quote_style)}))} ).fmt(fmt)?; let graphql_formatter_configuration = @@ -331,11 +337,11 @@ impl Display for RageConfiguration<'_> { 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(graphql_linter.enabled)}))} - {KeyValuePair("Recommended", markup!({DebugDisplay(linter_configuration.recommended.unwrap_or_default())}))} + {KeyValuePair("JavaScript enabled", markup!({DisplayOption(javascript_linter.enabled)}))} + {KeyValuePair("JSON enabled", markup!({DisplayOption(json_linter.enabled)}))} + {KeyValuePair("CSS enabled", markup!({DisplayOption(css_linter.enabled)}))} + {KeyValuePair("GraphQL enabled", markup!({DisplayOption(graphql_linter.enabled)}))} + {KeyValuePair("Recommended", markup!({DisplayOption(linter_configuration.recommended)}))} {RageConfigurationLintRules("Enabled rules", linter_configuration)} ).fmt(fmt)?; } diff --git a/crates/biome_cli/src/commands/search.rs b/crates/biome_cli/src/commands/search.rs index 2028b1ade9f6..50bfc0ef7e10 100644 --- a/crates/biome_cli/src/commands/search.rs +++ b/crates/biome_cli/src/commands/search.rs @@ -1,9 +1,8 @@ use crate::cli_options::CliOptions; use crate::commands::CommandRunner; use crate::{CliDiagnostic, Execution, TraversalMode}; -use biome_configuration::{ - vcs::PartialVcsConfiguration, PartialConfiguration, PartialFilesConfiguration, -}; +use biome_configuration::vcs::VcsConfiguration; +use biome_configuration::{Configuration, FilesConfiguration}; use biome_console::Console; use biome_deserialize::Merge; use biome_fs::FileSystem; @@ -15,12 +14,12 @@ use biome_service::{Workspace, WorkspaceError}; use std::ffi::OsString; pub(crate) struct SearchCommandPayload { - pub(crate) files_configuration: Option, + pub(crate) files_configuration: Option, pub(crate) paths: Vec, pub(crate) pattern: String, pub(crate) language: Option, pub(crate) stdin_file_path: Option, - pub(crate) vcs_configuration: Option, + pub(crate) vcs_configuration: Option, } impl CommandRunner for SearchCommandPayload { @@ -31,7 +30,7 @@ impl CommandRunner for SearchCommandPayload { loaded_configuration: LoadedConfiguration, _fs: &dyn FileSystem, _console: &mut dyn Console, - ) -> Result { + ) -> Result { let LoadedConfiguration { mut configuration, .. } = loaded_configuration; @@ -46,7 +45,7 @@ impl CommandRunner for SearchCommandPayload { fn get_files_to_process( &self, _fs: &dyn FileSystem, - _configuration: &PartialConfiguration, + _configuration: &Configuration, ) -> Result, CliDiagnostic> { Ok(self.paths.clone()) } diff --git a/crates/biome_cli/src/execute/migrate.rs b/crates/biome_cli/src/execute/migrate.rs index ae9fbfc04e24..b2fca5718a88 100644 --- a/crates/biome_cli/src/execute/migrate.rs +++ b/crates/biome_cli/src/execute/migrate.rs @@ -3,7 +3,7 @@ use crate::diagnostics::MigrationDiagnostic; use crate::execute::diagnostics::{ContentDiffAdvice, MigrateDiffDiagnostic}; use crate::{CliDiagnostic, CliSession}; use biome_analyze::AnalysisFilter; -use biome_configuration::PartialConfiguration; +use biome_configuration::Configuration; use biome_console::{markup, ConsoleExt}; use biome_deserialize::json::deserialize_from_json_ast; use biome_deserialize::Merge; @@ -90,8 +90,7 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> data: prettier_config, } = prettier::read_config_file(fs, console)?; let biome_config = - deserialize_from_json_ast::(&parsed.tree(), "") - .into_deserialized(); + deserialize_from_json_ast::(&parsed.tree(), "").into_deserialized(); let Some(mut biome_config) = biome_config else { return Ok(()); }; @@ -174,8 +173,7 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> data: eslint_config, } = eslint::read_eslint_config(fs, console)?; let biome_config = - deserialize_from_json_ast::(&parsed.tree(), "") - .into_deserialized(); + deserialize_from_json_ast::(&parsed.tree(), "").into_deserialized(); let Some(mut biome_config) = biome_config else { return Ok(()); }; 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 ad8bbe3e6883..f79550f2b1db 100644 --- a/crates/biome_cli/src/execute/migrate/eslint_to_biome.rs +++ b/crates/biome_cli/src/execute/migrate/eslint_to_biome.rs @@ -30,7 +30,7 @@ impl eslint_eslint::AnyConfigData { pub(crate) fn into_biome_config( self, options: &MigrationOptions, - ) -> (biome_config::PartialConfiguration, MigrationResults) { + ) -> (biome_config::Configuration, MigrationResults) { match self { Self::Flat(config) => config.into_biome_config(options), Self::Legacy(config) => config.into_biome_config(options), @@ -42,10 +42,10 @@ impl eslint_eslint::FlatConfigData { pub(crate) fn into_biome_config( self, options: &MigrationOptions, - ) -> (biome_config::PartialConfiguration, MigrationResults) { + ) -> (biome_config::Configuration, MigrationResults) { let mut results = MigrationResults::default(); - let mut biome_config = biome_config::PartialConfiguration::default(); - let mut linter = biome_config::PartialLinterConfiguration::default(); + let mut biome_config = biome_config::Configuration::default(); + let mut linter = biome_config::LinterConfiguration::default(); let mut overrides = biome_config::Overrides::default(); let global_config_object = if self.0.len() == 1 { // If there is a single config object, then we use it as the global config @@ -66,7 +66,7 @@ impl eslint_eslint::FlatConfigData { .globals .enabled() .collect::>(); - let js_config = biome_config::PartialJavascriptConfiguration { + let js_config = biome_config::JsConfiguration { globals: Some(globals), ..Default::default() }; @@ -105,7 +105,7 @@ impl eslint_eslint::FlatConfigData { .globals .enabled() .collect::>(); - let js_config = biome_config::PartialJavascriptConfiguration { + let js_config = biome_config::JsConfiguration { globals: Some(globals), ..Default::default() }; @@ -128,18 +128,18 @@ impl eslint_eslint::LegacyConfigData { pub(crate) fn into_biome_config( self, options: &MigrationOptions, - ) -> (biome_config::PartialConfiguration, MigrationResults) { + ) -> (biome_config::Configuration, MigrationResults) { let mut results = MigrationResults::default(); - let mut biome_config = biome_config::PartialConfiguration::default(); + let mut biome_config = biome_config::Configuration::default(); if !self.globals.is_empty() { let globals = self.globals.enabled().collect::>(); - let js_config = biome_config::PartialJavascriptConfiguration { + let js_config = biome_config::JsConfiguration { globals: Some(globals), ..Default::default() }; biome_config.javascript = Some(js_config) } - let mut linter = biome_config::PartialLinterConfiguration::default(); + let mut linter = biome_config::LinterConfiguration::default(); let mut rules = self.rules.into_biome_rules(options, &mut results); rules.recommended = Some(false); linter.rules = Some(rules); @@ -160,7 +160,7 @@ impl eslint_eslint::LegacyConfigData { .globals .enabled() .collect::>(); - let js_config = biome_config::PartialJavascriptConfiguration { + let js_config = biome_config::JsConfiguration { globals: Some(globals), ..Default::default() }; diff --git a/crates/biome_cli/src/execute/migrate/prettier.rs b/crates/biome_cli/src/execute/migrate/prettier.rs index 435ed5626cc9..09e702786fd8 100644 --- a/crates/biome_cli/src/execute/migrate/prettier.rs +++ b/crates/biome_cli/src/execute/migrate/prettier.rs @@ -1,6 +1,7 @@ use super::{eslint_eslint::ShorthandVec, node}; use crate::diagnostics::MigrationDiagnostic; use crate::CliDiagnostic; +use biome_configuration::javascript::JsFormatterConfiguration; use biome_console::{markup, Console, ConsoleExt}; use biome_deserialize::json::deserialize_from_json_str; use biome_deserialize_macros::Deserializable; @@ -185,10 +186,10 @@ impl From for QuoteProperties { } } -impl TryFrom for biome_configuration::PartialConfiguration { +impl TryFrom for biome_configuration::Configuration { type Error = ParseFormatNumberError; fn try_from(value: PrettierConfiguration) -> Result { - let mut result = biome_configuration::PartialConfiguration::default(); + let mut result = biome_configuration::Configuration::default(); let line_width = LineWidth::try_from(value.print_width)?; let indent_width = IndentWidth::try_from(value.tab_width)?; @@ -197,20 +198,20 @@ impl TryFrom for biome_configuration::PartialConfiguratio } else { biome_formatter::IndentStyle::Space }; - let formatter = biome_configuration::PartialFormatterConfiguration { + let formatter = biome_configuration::FormatterConfiguration { indent_width: Some(indent_width), line_width: Some(line_width), indent_style: Some(indent_style), line_ending: Some(value.end_of_line.into()), bracket_same_line: Some(value.bracket_line.into()), attribute_position: Some(AttributePosition::default()), - format_with_errors: Some(false), + format_with_errors: Some(false.into()), ignore: None, include: None, - enabled: Some(true), + enabled: Some(true.into()), // editorconfig support is intentionally set to true, because prettier always reads the editorconfig file // see: https://github.com/prettier/prettier/issues/15255 - use_editorconfig: Some(true), + use_editorconfig: Some(true.into()), bracket_spacing: Some(BracketSpacing::default()), }; result.formatter = Some(formatter); @@ -230,7 +231,7 @@ impl TryFrom for biome_configuration::PartialConfiguratio } else { QuoteStyle::Double }; - let js_formatter = biome_configuration::PartialJavascriptFormatter { + let js_formatter = JsFormatterConfiguration { indent_width: None, line_width: None, indent_style: None, @@ -247,7 +248,7 @@ impl TryFrom for biome_configuration::PartialConfiguratio jsx_quote_style: Some(jsx_quote_style), attribute_position: Some(AttributePosition::default()), }; - let js_config = biome_configuration::PartialJavascriptConfiguration { + let js_config = biome_configuration::JsConfiguration { formatter: Some(js_formatter), ..Default::default() }; @@ -337,7 +338,7 @@ impl TryFrom for biome_configuration::OverridePattern { QuoteStyle::Double } }); - let js_formatter = biome_configuration::PartialJavascriptFormatter { + let js_formatter = JsFormatterConfiguration { bracket_same_line: options.bracket_line.map(Into::into), arrow_parentheses: options.arrow_parens.map(|arrow_parens| arrow_parens.into()), semicolons, @@ -349,7 +350,7 @@ impl TryFrom for biome_configuration::OverridePattern { jsx_quote_style, ..Default::default() }; - let js_config = biome_configuration::PartialJavascriptConfiguration { + let js_config = biome_configuration::JsConfiguration { formatter: Some(js_formatter), ..Default::default() }; diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index 8ec1b75a7a02..93e1c7b6229e 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -554,7 +554,15 @@ fn applies_custom_configuration_over_config_file_issue_3175_v1() { let (fs, result) = run_cli( fs, &mut console, - Args::from(["format", "--quote-style", "single", file_path.as_str()].as_slice()), + Args::from( + [ + "format", + "--javascript-formatter-quote-style", + "single", + file_path.as_str(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -657,7 +665,7 @@ fn applies_custom_quote_style() { Args::from( [ "format", - "--quote-style", + "--javascript-formatter-quote-style", "single", "--quote-properties", "preserve", diff --git a/crates/biome_cli/tests/snapshots/main_commands_check/check_help.snap b/crates/biome_cli/tests/snapshots/main_commands_check/check_help.snap index 9cef47e40d9e..96494eea3a44 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_check/check_help.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_check/check_help.snap @@ -28,20 +28,25 @@ The configuration that is contained inside the file `biome.json` 1 MiB --files-ignore-unknown= Tells Biome to not emit diagnostics when handling files that doesn't know - --use-editorconfig= Use any `.editorconfig` files to configure the formatter. - Configuration in `biome.json` will override `.editorconfig` - configuration. Default: false. --indent-style= The indent style. --indent-width=NUMBER The size of the indentation, 2 by default --line-ending= The type of line ending. --line-width=NUMBER What's the max width of a line. Defaults to 80. - --attribute-position= The attribute position style in HTMLish languages. By - default auto. + --attribute-position= The attribute position style in HTML-ish languages. + Defaults to auto. --bracket-same-line= Put the `>` of a multi-line HTML or JSX element at the end of the last line instead of being alone on the next line (does not apply to self closing elements). --bracket-spacing= Whether to insert spaces around brackets in object literals. Defaults to true. + --use-editorconfig= Use any `.editorconfig` files to configure the formatter. + Configuration in `biome.json` will override `.editorconfig` + configuration. + Default: `false`. + --jsx-everywhere= When enabled, files like `.js`/`.ts` can contain JSX syntax. + Defaults to `true`. + --javascript-formatter-enabled= Control the formatter for JavaScript (and its + super languages) files. --jsx-quote-style= The type of quotes used in JSX. Defaults to double. --quote-properties= When properties in objects are quoted. Defaults to asNeeded. @@ -51,8 +56,9 @@ The configuration that is contained inside the file `biome.json` or only in for statements where it is necessary because of ASI. --arrow-parentheses= Whether to add non-necessary parentheses to arrow functions. Defaults to "always". - --javascript-formatter-enabled= Control the formatter for JavaScript (and its - super languages) files. + --bracket-same-line= Whether to hug the closing bracket of multiline HTML/JSX + tags to the end of the last line, rather than being alone on the + following line. Defaults to false. --javascript-formatter-indent-style= The indent style applied to JavaScript (and its super languages) files. --javascript-formatter-indent-width=NUMBER The size of the indentation applied to @@ -61,16 +67,13 @@ The configuration that is contained inside the file `biome.json` JavaScript (and its super languages) files. --javascript-formatter-line-width=NUMBER What's the max width of a line applied to JavaScript (and its super languages) files. Defaults to 80. - --quote-style= The type of quotes used in JavaScript code. Defaults to - double. + --javascript-formatter-quote-style= The type of quotes used in JavaScript + code. Defaults to double. --javascript-attribute-position= The attribute position style in jsx elements. Defaults to auto. - --javascript-bracket-same-line= Whether to hug the closing bracket of multiline - HTML/JSX tags to the end of the last line, rather than being alone on - the following line. Defaults to false. --javascript-linter-enabled= Control the linter for JavaScript (and its super languages) files. - --javascript-assists-enabled= Control the linter for JavaScript (and its super + --javascript-assist-enabled= Control the assist for JavaScript (and its super languages) files. --json-formatter-enabled= Control the formatter for JSON (and its super languages) files. @@ -91,7 +94,7 @@ The configuration that is contained inside the file `biome.json` Defaults to "followSource". --json-linter-enabled= Control the linter for JSON (and its super languages) files. - --json-assist-enabled= Control the linter for JSON (and its super languages) + --json-assist-enabled= Control the assist for JSON (and its super languages) files. --css-formatter-enabled= Control the formatter for CSS (and its super languages) files. @@ -106,7 +109,7 @@ The configuration that is contained inside the file `biome.json` --css-formatter-quote-style= The type of quotes used in CSS code. Defaults to double. --css-linter-enabled= Control the linter for CSS files. - --css-assist-enabled= Control the assists for CSS files. + --css-assist-enabled= Control the assist for CSS files. --graphql-formatter-enabled= Control the formatter for GraphQL files. --graphql-formatter-indent-style= The indent style applied to GraphQL files. --graphql-formatter-indent-width=NUMBER The size of the indentation applied to GraphQL @@ -118,6 +121,7 @@ The configuration that is contained inside the file `biome.json` --graphql-formatter-quote-style= The type of quotes used in GraphQL code. Defaults to double. --graphql-linter-enabled= Control the formatter for GraphQL files. + --graphql-assist-enabled= Control the formatter for GraphQL files. --grit-formatter-enabled= Control the formatter for Grit files. --grit-formatter-indent-style= The indent style applied to Grit files. --grit-formatter-indent-width=NUMBER The size of the indentation applied to Grit files. @@ -125,6 +129,28 @@ The configuration that is contained inside the file `biome.json` --grit-formatter-line-ending= The type of line ending applied to Grit files. --grit-formatter-line-width=NUMBER What's the max width of a line applied to Grit files. Defaults to 80. + --grit-linter-enabled= Control the linter for Grit files. + --grit-assist-enabled= Control the assist functionality for Grit files. + --html-formatter-enabled= Control the formatter for HTML (and its super + languages) files. + --html-formatter-indent-style= The indent style applied to HTML (and its super + languages) files. + --html-formatter-indent-width=NUMBER The size of the indentation applied to HTML (and its + super languages) files. Default to 2. + --html-formatter-line-ending= The type of line ending applied to HTML (and its + super languages) files. + --html-formatter-line-width=NUMBER What's the max width of a line applied to HTML (and its + super languages) files. Defaults to 80. + --html-formatter-attribute-position= The attribute position style in HTML + elements. Defaults to auto. + --html-formatter-bracket-same-line= Whether to hug the closing bracket of + multiline HTML tags to the end of the last line, rather than being + alone on the following line. Defaults to false. + --html-formatter-whitespace-sensitivity= Whether to account for whitespace + sensitivity when formatting HTML (and its super languages). Defaults + to "strict". + --html-formatter-indent-script-and-style= Whether to indent the `