Skip to content

Commit

Permalink
chore(editorconfig): reenable editorconfig loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed May 24, 2024
1 parent 9f08204 commit 24c30ff
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
46 changes: 24 additions & 22 deletions crates/biome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down
44 changes: 22 additions & 22 deletions crates/biome_cli/src/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion crates/biome_cli/tests/cases/editorconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 24c30ff

Please sign in to comment.