Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(editorconfig): reenable editorconfig loading #2971

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ indent_size = 2

# YAML doesn't support hard tabs 🙃
# Templates that will be weird with hard tabs in the website editor
[{**.yml,**.md,**.rs,**.mdx,justfile,**.json}]
[**.yml]
indent_style = space

[**.md]
indent_style = space

[**.mdx]
indent_style = space

[justfile]
indent_style = space

[**.json]
indent_style = space

[*.rs]
indent_style = space
indent_size = 4
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `.editorconfig`

```editorconfig

[*]
max_line_length = 300

```

## `test.js`

```js
console.log("really long string that should cause a break if the line width remains at the default 80 characters");

```

# Emitted Messages

```block
Formatted 1 file in <TIME>. No fixes needed.
```