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

Fixed [#8360](https://github.com/biomejs/biome/issues/8360): GritQL plugins defined in child configurations with `extends: "//"` now work correctly.
67 changes: 67 additions & 0 deletions crates/biome_cli/tests/cases/monorepo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,3 +676,70 @@ fn should_ignore_linter_nested_file() {
result,
));
}

#[test]
fn plugins_in_child_config_with_extends_root() {
let mut fs = TemporaryFs::new("plugins_in_child_config_with_extends_root");

fs.create_file(
"biome.json",
r#"{
"linter": {
"enabled": true
}
}"#,
);

fs.create_file(
"packages/mobile/biome.json",
r#"{
"extends": "//",
"plugins": ["./biome-plugins/no-object-assign.grit"],
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}"#,
);

fs.create_file(
"packages/mobile/biome-plugins/no-object-assign.grit",
r#"`$fn($args)` where {
$fn <: `Object.assign`,
register_diagnostic(
span = $fn,
message = "Prefer object spread instead of Object.assign()",
severity = "warn"
)
}"#,
);

fs.create_file(
"packages/mobile/src/file.js",
r#"const merged = Object.assign({}, a, b);
"#,
);

let mut console = BufferConsole::default();
let result = run_cli_with_dyn_fs(
Box::new(fs.create_os()),
&mut console,
Args::from(
[
"lint",
&format!("{}/packages/mobile/src/file.js", fs.cli_path()),
]
.as_slice(),
),
);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"plugins_in_child_config_with_extends_root",
fs.create_mem(),
console,
result,
));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
source: crates/biome_cli/tests/snap_test.rs
assertion_line: 432
expression: redactor(content)
---
## `packages/mobile/biome.json`

```json
{
"extends": "//",
"plugins": ["./biome-plugins/no-object-assign.grit"],
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
```

## `biome.json`

```json
{
"linter": {
"enabled": true
}
}
```

## `packages/mobile/biome-plugins/no-object-assign.grit`

```grit
`$fn($args)` where {
$fn <: `Object.assign`,
register_diagnostic(
span = $fn,
message = "Prefer object spread instead of Object.assign()",
severity = "warn"
)
}
```

## `packages/mobile/src/file.js`

```js
const merged = Object.assign({}, a, b);

```

# Emitted Messages

```block
packages/mobile/src/file.js:1:16 plugin ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Prefer object spread instead of Object.assign()

> 1 │ const merged = Object.assign({}, a, b);
│ ^^^^^^^^^^^^^
2 │


```

```block
packages/mobile/src/file.js:1:7 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━

! This variable merged is unused.

> 1 │ const merged = Object.assign({}, a, b);
│ ^^^^^^
2 │

i Unused variables are often the result of an incomplete refactoring, typos, or other sources of bugs.

i Unsafe fix: If this is intentional, prepend merged with an underscore.

1 │ - const·merged·=·Object.assign({},·a,·b);
1 │ + const·_merged·=·Object.assign({},·a,·b);
2 2 │


```

```block
Checked 1 file in <TIME>. No fixes applied.
Found 2 warnings.
```
9 changes: 1 addition & 8 deletions crates/biome_service/src/workspace/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,6 @@ impl Workspace for WorkspaceServer {
let mut diagnostics: Vec<biome_diagnostics::serde::Diagnostic> = vec![];
let workspace_directory = workspace_directory.map(|p| p.to_path_buf());
let is_root = configuration.is_root();
let extends_root = configuration.extends_root();
let mut settings = if !is_root {
if !self.projects.is_project_registered(project_key) {
return Err(WorkspaceError::no_project());
Expand Down Expand Up @@ -1034,14 +1033,8 @@ impl Workspace for WorkspaceServer {
.collect(),
)?;

let loading_directory = if extends_root {
self.projects.get_project_path(project_key)
} else {
workspace_directory.clone()
};

let plugin_diagnostics = self.load_plugins(
&loading_directory.clone().unwrap_or_default(),
&workspace_directory.clone().unwrap_or_default(),
&settings.as_all_plugins(),
);

Expand Down