From 24c30ff687e8130446b080d39774dba53137e004 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Fri, 24 May 2024 10:09:30 -0400 Subject: [PATCH] chore(editorconfig): reenable editorconfig loading --- crates/biome_cli/src/commands/check.rs | 46 ++++++++++---------- crates/biome_cli/src/commands/format.rs | 44 +++++++++---------- crates/biome_cli/tests/cases/editorconfig.rs | 1 - 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/crates/biome_cli/src/commands/check.rs b/crates/biome_cli/src/commands/check.rs index 2647501f73df..c652dfb2798e 100644 --- a/crates/biome_cli/src/commands/check.rs +++ b/crates/biome_cli/src/commands/check.rs @@ -9,8 +9,10 @@ use biome_configuration::{ organize_imports::PartialOrganizeImports, PartialConfiguration, PartialFormatterConfiguration, PartialLinterConfiguration, }; +use biome_console::{markup, ConsoleExt}; use biome_deserialize::Merge; -use biome_service::configuration::PartialConfigurationExt; +use biome_diagnostics::PrintDiagnostic; +use biome_service::configuration::{load_editorconfig, PartialConfigurationExt}; use biome_service::workspace::RegisterProjectFolderParams; use biome_service::{ configuration::{load_configuration, LoadedConfiguration}, @@ -80,34 +82,34 @@ pub(crate) fn check( session.app.console, cli_options.verbose, )?; - // let fs = &session.app.fs; - // let (editorconfig, editorconfig_diagnostics) = { - // let search_path = loaded_configuration - // .directory_path - // .clone() - // .unwrap_or_else(|| fs.working_directory().unwrap_or_default()); - // load_editorconfig(fs, search_path)? - // }; - // for diagnostic in editorconfig_diagnostics { - // session.app.console.error(markup! { - // {PrintDiagnostic::simple(&diagnostic)} - // }) - // } + let fs = &session.app.fs; + let (editorconfig, editorconfig_diagnostics) = { + let search_path = loaded_configuration + .directory_path + .clone() + .unwrap_or_else(|| fs.working_directory().unwrap_or_default()); + load_editorconfig(fs, search_path)? + }; + for diagnostic in editorconfig_diagnostics { + session.app.console.error(markup! { + {PrintDiagnostic::simple(&diagnostic)} + }) + } resolve_manifest(&session)?; let LoadedConfiguration { - configuration: mut fs_configuration, + configuration: biome_configuration, directory_path: configuration_path, .. } = loaded_configuration; - // let mut fs_configuration = if let Some(mut fs_configuration) = editorconfig { - // // this makes biome configuration take precedence over editorconfig configuration - // fs_configuration.merge_with(biome_configuration); - // fs_configuration - // } else { - // biome_configuration - // }; + let mut fs_configuration = if let Some(mut fs_configuration) = editorconfig { + // this makes biome configuration take precedence over editorconfig configuration + fs_configuration.merge_with(biome_configuration); + fs_configuration + } else { + biome_configuration + }; let formatter = fs_configuration .formatter diff --git a/crates/biome_cli/src/commands/format.rs b/crates/biome_cli/src/commands/format.rs index 125ef6662c2a..ec9fb9f7d37f 100644 --- a/crates/biome_cli/src/commands/format.rs +++ b/crates/biome_cli/src/commands/format.rs @@ -15,7 +15,7 @@ use biome_console::{markup, ConsoleExt}; use biome_deserialize::Merge; use biome_diagnostics::PrintDiagnostic; use biome_service::configuration::{ - load_configuration, LoadedConfiguration, PartialConfigurationExt, + load_configuration, load_editorconfig, LoadedConfiguration, PartialConfigurationExt }; use biome_service::workspace::{RegisterProjectFolderParams, UpdateSettingsParams}; use std::ffi::OsString; @@ -77,33 +77,33 @@ pub(crate) fn format( session.app.console, cli_options.verbose, )?; - // let fs = &session.app.fs; - // let (editorconfig, editorconfig_diagnostics) = { - // let search_path = loaded_configuration - // .directory_path - // .clone() - // .unwrap_or_else(|| fs.working_directory().unwrap_or_default()); - // load_editorconfig(fs, search_path)? - // }; - // for diagnostic in editorconfig_diagnostics { - // session.app.console.error(markup! { - // {PrintDiagnostic::simple(&diagnostic)} - // }) - // } + let fs = &session.app.fs; + let (editorconfig, editorconfig_diagnostics) = { + let search_path = loaded_configuration + .directory_path + .clone() + .unwrap_or_else(|| fs.working_directory().unwrap_or_default()); + load_editorconfig(fs, search_path)? + }; + for diagnostic in editorconfig_diagnostics { + session.app.console.error(markup! { + {PrintDiagnostic::simple(&diagnostic)} + }) + } resolve_manifest(&session)?; let LoadedConfiguration { - mut configuration, + configuration: biome_configuration, directory_path: configuration_path, .. } = loaded_configuration; - // let mut configuration = if let Some(mut configuration) = editorconfig { - // // this makes biome configuration take precedence over editorconfig configuration - // configuration.merge_with(biome_configuration); - // configuration - // } else { - // biome_configuration - // }; + let mut configuration = if let Some(mut configuration) = editorconfig { + // this makes biome configuration take precedence over editorconfig configuration + configuration.merge_with(biome_configuration); + configuration + } else { + biome_configuration + }; // TODO: remove in biome 2.0 let console = &mut *session.app.console; diff --git a/crates/biome_cli/tests/cases/editorconfig.rs b/crates/biome_cli/tests/cases/editorconfig.rs index 6c91a50425ec..1468716f8e8b 100644 --- a/crates/biome_cli/tests/cases/editorconfig.rs +++ b/crates/biome_cli/tests/cases/editorconfig.rs @@ -7,7 +7,6 @@ use bpaf::Args; use std::path::Path; #[test] -#[ignore = "enable once we have the configuration to turn it on"] fn should_use_editorconfig() { let mut fs = MemoryFileSystem::default(); let mut console = BufferConsole::default();