Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/brave-eagles-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#9463](https://github.com/biomejs/biome/issues/9463): the "Biome found a configuration file outside of the current working directory" diagnostic now includes the configuration file path and the working directory, giving users actionable information to debug the issue.
11 changes: 10 additions & 1 deletion crates/biome_cli/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ pub(crate) trait CommandRunner {
mut loaded_location,
} = loaded_configuration;

// Save the config file path for diagnostics before merge_configuration consumes it
let config_file_path = file_path.clone();

// Merge the FS configuration with the CLI arguments
let configuration = self.merge_configuration(
configuration,
Expand All @@ -387,8 +390,14 @@ pub(crate) trait CommandRunner {
&root_configuration_dir
};
if !loaded_location.is_in_project() {
let config_file_path = config_file_path
.as_ref()
.map_or_else(|| "<unknown>".to_string(), |p| p.to_string());
console.log(markup! {
{PrintDiagnostic::simple(&ConfigurationOutsideProject)}
{PrintDiagnostic::simple(&ConfigurationOutsideProject {
config_path: config_file_path,
working_directory: working_dir.to_string(),
})}
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
```block
project ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i Biome found a configuration file outside of the current working directory. If the configuration enables the scanner, Biome might scan the whole file system. This behaviour will be fixed in the next major version.
i Biome found the configuration file <CONFIG_DIR>/biome.json outside of the current working directory . If the configuration enables the scanner, Biome might scan the whole file system. This behaviour will be fixed in the next major version.


```
Expand Down
27 changes: 26 additions & 1 deletion crates/biome_lsp/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,32 @@ impl Session {
}
};
if !loaded_configuration.loaded_location.is_in_project() {
let message = PrintDescription(&ConfigurationOutsideProject).to_string();
let config_path = loaded_configuration
.file_path
.as_ref()
.map_or_else(|| "<unknown>".to_string(), |p| p.to_string());
let working_directory = match &base_path {
ConfigurationPathHint::FromLsp(path)
| ConfigurationPathHint::FromWorkspace(path) => path.to_string(),
ConfigurationPathHint::FromUser(path) => {
let fs = self.workspace.fs();
if fs.path_is_file(path) {
path.parent()
.map_or("<unknown>".to_string(), |p| p.to_string())
} else {
path.to_string()
}
}
ConfigurationPathHint::FromUserExternal(_) => self
.base_path()
.map_or("<unknown>".to_string(), |p| p.to_string()),
ConfigurationPathHint::None => "<unknown>".to_string(),
};
let message = PrintDescription(&ConfigurationOutsideProject {
config_path,
working_directory,
})
.to_string();
self.client.log_message(MessageType::INFO, message).await;
}

Expand Down
12 changes: 9 additions & 3 deletions crates/biome_service/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,19 @@ pub struct WatchError {
pub reason: String,
}

#[derive(Debug, Default, Diagnostic, Serialize, Deserialize)]
#[derive(Debug, Diagnostic, Serialize, Deserialize)]
#[diagnostic(
category = "project",
severity = Hint,
message = "Biome found a configuration file outside of the current working directory. If the configuration enables the scanner, Biome might scan the whole file system. This behaviour will be fixed in the next major version.",
message(
message("Biome found the configuration file "{self.config_path}" outside of the current working directory "{self.working_directory}". If the configuration enables the scanner, Biome might scan the whole file system. This behaviour will be fixed in the next major version."),
description = "Biome found the configuration file {config_path} outside of the current working directory {working_directory}. If the configuration enables the scanner, Biome might scan the whole file system. This behaviour will be fixed in the next major version."
),
)]
pub struct ConfigurationOutsideProject;
pub struct ConfigurationOutsideProject {
pub config_path: String,
pub working_directory: String,
}

#[cfg(test)]
mod test {
Expand Down