+
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/skating-scanner-skips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#7062](https://github.com/biomejs/biome/issues/7062): Biome now correctly considers extended configs when determining the mode for the scanner.
33 changes: 14 additions & 19 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use biome_diagnostics::{Diagnostic, PrintDiagnostic, Severity};
use biome_fs::{BiomePath, FileSystem};
use biome_grit_patterns::GritTargetLanguage;
use biome_resolver::FsWithResolverProxy;
use biome_service::configuration::{LoadedConfiguration, load_configuration, load_editorconfig};
use biome_service::configuration::{
LoadedConfiguration, ProjectScanComputer, load_configuration, load_editorconfig,
};
use biome_service::documentation::Doc;
use biome_service::projects::ProjectKey;
use biome_service::workspace::{
Expand Down Expand Up @@ -921,27 +923,20 @@ pub(crate) trait CommandRunner: Sized {
let paths = self.get_files_to_process(fs, &configuration)?;
let paths = validated_paths_for_execution(paths, &execution, &working_dir)?;

let params = if let TraversalMode::Lint { only, skip, .. } = execution.traversal_mode() {
OpenProjectParams {
path: BiomePath::new(project_dir),
open_uninitialized: true,
only_rules: Some(only.clone()),
skip_rules: Some(skip.clone()),
}
} else {
OpenProjectParams {
path: BiomePath::new(project_dir),
open_uninitialized: true,
only_rules: None,
skip_rules: None,
}
};

// Open the project
let open_project_result = workspace.open_project(params)?;
let open_project_result = workspace.open_project(OpenProjectParams {
path: BiomePath::new(project_dir),
open_uninitialized: true,
})?;

let scan_kind_computer =
if let TraversalMode::Lint { only, skip, .. } = execution.traversal_mode() {
ProjectScanComputer::new(&configuration).with_rule_selectors(skip, only)
} else {
ProjectScanComputer::new(&configuration)
};
let scan_kind = derive_best_scan_kind(
open_project_result.scan_kind,
scan_kind_computer.compute(),
&execution,
&root_configuration_dir,
&working_dir,
Expand Down
58 changes: 58 additions & 0 deletions crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4079,6 +4079,64 @@ bar();"#
));
}

#[test]
fn linter_enables_project_domain_based_on_extended_config() {
let mut console = BufferConsole::default();
let fs = MemoryFileSystem::default();

fs.insert(
Utf8Path::new("biome.json").into(),
r#"{ "extends": ["biome.base.json"] }"#.as_bytes(),
);

fs.insert(
Utf8Path::new("biome.base.json").into(),
r#"{
"linter": {
"rules": {
"nursery": {
"noFloatingPromises": "on"
}
}
}
}"#
.as_bytes(),
);

let file = Utf8Path::new("src/foo.ts");
fs.insert(
file.into(),
r#"export function foo(): Foo {}

export async function bar() {}"#
.as_bytes(),
);

let file = Utf8Path::new("src/index.ts");
fs.insert(
file.into(),
r#"import { foo, bar } from "./foo.ts";

fn(foo());

bar();"#
.as_bytes(),
);

let (fs, result) = run_cli_with_server_workspace(
fs,
&mut console,
Args::from(["lint", file.as_str()].as_slice()),
);
assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"linter_enables_project_domain_based_on_extended_config",
fs,
console,
result,
));
}

#[test]
fn should_apply_root_settings_with_stdin_file_path() {
let mut fs = TemporaryFs::new("should_apply_root_settings_with_stdin_file_path");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: redactor(content)
---
## `biome.json`

```json
{ "extends": ["biome.base.json"] }
```

## `biome.base.json`

```json
{
"linter": {
"rules": {
"nursery": {
"noFloatingPromises": "on"
}
}
}
}
```

## `src/foo.ts`

```ts
export function foo(): Foo {}

export async function bar() {}
```

## `src/index.ts`

```ts
import { foo, bar } from "./foo.ts";

fn(foo());

bar();
```

# Emitted Messages

```block
src/index.ts:5:1 lint/nursery/noFloatingPromises ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i A "floating" Promise was found, meaning it is not properly handled and could lead to ignored errors or unexpected behavior.

3 │ fn(foo());
4 │
> 5 │ bar();
│ ^^^^^^

i This happens when a Promise is not awaited, lacks a `.catch` or `.then` rejection handler, or is not explicitly ignored using the `void` operator.


```

```block
Checked 1 file in <TIME>. No fixes applied.
```
4 changes: 1 addition & 3 deletions crates/biome_formatter_test/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ impl<'a> SpecTestFile<'a> {
"The input '{spec_input_file}' must exist and be a file.",
);

let OpenProjectResult { project_key, .. } = app
let OpenProjectResult { project_key } = app
.workspace
.open_project(OpenProjectParams {
path: BiomePath::new(""),
open_uninitialized: true,
only_rules: None,
skip_rules: None,
})
.unwrap();

Expand Down
45 changes: 23 additions & 22 deletions crates/biome_lsp/src/handlers/text_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use std::sync::Arc;
use crate::diagnostics::LspError;
use crate::utils::apply_document_changes;
use crate::{documents::Document, session::Session};
use biome_fs::BiomePath;
use biome_configuration::ConfigurationPathHint;
use biome_service::workspace::{
ChangeFileParams, CloseFileParams, DocumentFileSource, FeaturesBuilder, FileContent,
GetFileContentParams, IgnoreKind, IsPathIgnoredParams, OpenFileParams, OpenProjectParams,
ScanKind,
GetFileContentParams, IgnoreKind, IsPathIgnoredParams, OpenFileParams,
};
use tower_lsp_server::lsp_types;
use tracing::{debug, error, field, info};
Expand Down Expand Up @@ -35,26 +34,28 @@ pub(crate) async fn did_open(
Some(project_key) => project_key,
None => {
info!("No open project for path: {path:?}. Opening new project.");
let parent_path = BiomePath::new(
path.parent()
.map(|parent| parent.to_path_buf())
.unwrap_or_default(),
);
let result = session.workspace.open_project(OpenProjectParams {
path: parent_path.clone(),
open_uninitialized: true,
skip_rules: None,
only_rules: None,
})?;
let scan_kind = if result.scan_kind.is_none() {
ScanKind::KnownFiles
} else {
result.scan_kind
};
session
.insert_and_scan_project(result.project_key, parent_path, scan_kind)
let parent_path = path
.parent()
.map(|parent| parent.to_path_buf())
.unwrap_or_default();
let status = session
.load_biome_configuration_file(ConfigurationPathHint::FromLsp(parent_path))
.await;
result.project_key
debug!("Configuration status: {status:?}");
session.set_configuration_status(status);

if status.is_loaded() {
match session.project_for_path(&path) {
Some(project_key) => project_key,
None => {
error!("Could not find project for {path}");
return Ok(());
}
}
} else {
error!("Configuration could not be loaded for {path}");
return Ok(());
}
}
};

Expand Down
43 changes: 9 additions & 34 deletions crates/biome_lsp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::session::{
};
use crate::utils::{into_lsp_error, panic_to_lsp_error};
use crate::{handlers, requests};
use biome_configuration::ConfigurationPathHint;
use biome_console::markup;
use biome_diagnostics::panic::PanicError;
use biome_fs::{ConfigName, MemoryFileSystem, OsFileSystem};
use biome_resolver::FsWithResolverProxy;
use biome_service::workspace::{
CloseProjectParams, OpenProjectParams, RageEntry, RageParams, RageResult, ScanKind,
ServiceDataNotification,
CloseProjectParams, RageEntry, RageParams, RageResult, ServiceDataNotification,
};
use biome_service::{WatcherInstruction, WorkspaceServer};
use crossbeam::channel::{Sender, bounded};
Expand Down Expand Up @@ -412,39 +412,14 @@ impl LanguageServer for LSPServer {

for added in &params.event.added {
if let Ok(project_path) = self.session.file_path(&added.uri) {
let result = self
let status = self
.session
.workspace
.open_project(OpenProjectParams {
path: project_path.clone(),
open_uninitialized: true,
only_rules: None,
skip_rules: None,
})
.map_err(LspError::from);

match result {
Ok(result) => {
let scan_kind = if result.scan_kind.is_none() {
ScanKind::KnownFiles
} else {
result.scan_kind
};
self.session
.insert_and_scan_project(
result.project_key,
project_path.clone(),
scan_kind,
)
.await;

self.session.update_all_diagnostics().await;
}
Err(err) => {
error!("Failed to add project to the workspace: {err}");
self.notify_error(err).await;
}
}
.load_biome_configuration_file(ConfigurationPathHint::FromWorkspace(
project_path.to_path_buf(),
))
.await;
debug!("Configuration status: {status:?}");
self.session.set_configuration_status(status);
}
}
}
Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载