Skip to content

Commit f05a3c3

Browse files
fix: closed various bugs (#11715)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 0e9fe53 commit f05a3c3

33 files changed

Lines changed: 605 additions & 209 deletions

‎.changeset/chatty-planes-smell.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#7771](https://github.com/biomejs/biome/issues/7771): Grit plugins that use `sequential` no longer panic when Biome processes files.

‎.changeset/hip-flies-spend.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#7795](https://github.com/biomejs/biome/issues/7795). The [`noJsxLiterals`](https://biomejs.dev/linter/rules/no-jsx-literals/) rule now ignores surrounding whitespace when matching literals against `allowedStrings`.

‎.changeset/plain-lemons-swim.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#7722](https://github.com/biomejs/biome/issues/7722): [`noUnusedImports`](https://biomejs.dev/linter/rules/no-unused-imports/) no longer reports type-only imports used in computed names of declared class properties.

‎.changeset/rare-heads-brush.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#5447](https://github.com/biomejs/biome/issues/5447), so the GitHub reporter now associates annotations with the correct files when Biome runs from a nested directory.

‎.changeset/six-signs-thank.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#7711](https://github.com/biomejs/biome/issues/7711): `biome lint --suppress` no longer fails with conflicting rule fixes when multiple diagnostics target a declaration preceded by a multiline comment.

‎.changeset/thirty-facts-hear.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#7603](https://github.com/biomejs/biome/issues/7603): [`useSingleJsDocAsterisk`](https://biomejs.dev/linter/rules/use-single-js-doc-asterisk/) no longer reports asterisks that are part of JSDoc comment content, such as italic text, as extra line markers.

‎AGENTS.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Load [testing-codegen](./.claude/skills/testing-codegen/SKILL.md) for test fixtu
3131

3232
Required generated artifacts:
3333

34-
| Changed source | Required command |
35-
|--------------------------|------------------------------------------------------------------------|
36-
| Grammar `.ungram` | `just gen-grammar <lang>` |
37-
| Lint rule in `*_analyze` | `just gen-rules` and `just gen-configuration` if you changed rule name |
34+
| Changed source | Required command |
35+
|------------------------------|-----------------------------------------------|
36+
| Grammar `.ungram` | `just gen-grammar <lang>` |
37+
| Change a rule or action name | `just gen-rules` and `just gen-configuration` |
3838

3939
Bindings and other full analyzer outputs may be left to the CI Autofix job unless they are needed for local verification.
4040

‎crates/biome_cli/src/reporter/github.rs‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::reporter::{Reporter, ReporterVisitor, ReporterWriter};
22
use crate::runner::execution::Execution;
33
use crate::{DiagnosticsPayload, TraversalSummary};
44
use biome_console::markup;
5-
use biome_diagnostics::PrintGitHubDiagnostic;
5+
use biome_diagnostics::{PrintGitHubDiagnostic, Resource};
66
use camino::{Utf8Path, Utf8PathBuf};
77
use std::io;
88

@@ -49,14 +49,23 @@ impl ReporterVisitor for GithubReporterVisitor {
4949
_execution: &dyn Execution,
5050
diagnostics_payload: &DiagnosticsPayload,
5151
verbose: bool,
52-
_working_directory: Option<&Utf8Path>,
52+
working_directory: Option<&Utf8Path>,
5353
) -> io::Result<()> {
5454
for diagnostic in &diagnostics_payload.diagnostics {
55-
if diagnostic.severity() >= diagnostics_payload.diagnostic_level {
56-
if !diagnostic.tags().is_verbose() {
57-
writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
58-
} else if diagnostic.tags().is_verbose() && verbose {
59-
writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
55+
if diagnostic.severity() >= diagnostics_payload.diagnostic_level
56+
&& (!diagnostic.tags().is_verbose() || verbose)
57+
{
58+
let file_path = match diagnostic.location().resource {
59+
Some(Resource::File(file_path)) if Utf8Path::new(file_path).is_relative() => {
60+
working_directory.map(|working_directory| working_directory.join(file_path))
61+
}
62+
_ => None,
63+
};
64+
let diagnostic = PrintGitHubDiagnostic(diagnostic);
65+
if let Some(file_path) = file_path {
66+
writer.log(markup! {{diagnostic.with_file_path(file_path.as_str())}});
67+
} else {
68+
writer.log(markup! {{diagnostic}});
6069
}
6170
}
6271
}

‎crates/biome_cli/tests/cases/regression_tests.rs‎

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,144 @@ const imported = <Fragment><span>Child</span></Fragment>;
374374
result,
375375
));
376376
}
377+
378+
#[test]
379+
fn issue_7771() {
380+
let fs = MemoryFileSystem::default();
381+
let mut console = BufferConsole::default();
382+
383+
fs.insert(
384+
"biome.json".into(),
385+
br#"{
386+
"assist": {
387+
"actions": {
388+
"source": {
389+
"organizeImports": {
390+
"level": "on",
391+
"options": {
392+
"groups": [
393+
"@app", "@app/**",
394+
"@pages", "@pages/**",
395+
"@widgets", "@widgets/**",
396+
"@features", "@features/**",
397+
"@entities", "@entities/**",
398+
"@shared", "@shared/**",
399+
":PACKAGE:", ":ALIAS:", ":PATH:"
400+
]
401+
}
402+
}
403+
}
404+
}
405+
},
406+
"plugins": [
407+
"./tools/biome/plugins/fsd-depth.grit",
408+
"./tools/biome/plugins/fsd-deps.grit"
409+
]
410+
}"#,
411+
);
412+
fs.insert(
413+
"tools/biome/plugins/fsd-depth.grit".into(),
414+
br#"engine biome(1.0)
415+
language js(typescript,jsx)
416+
417+
sequential {
418+
`import $what from $src` where {
419+
$src <: r"^\"@(app|pages|widgets|features|entities|shared)\/[^\/]+\/.+\"$",
420+
register_diagnostic(
421+
span = $src,
422+
message = "Only 2 level paths are allowed (e.g. @layer/name).",
423+
severity = "error"
424+
)
425+
},
426+
427+
`import $src` where {
428+
$src <: r"^\"@(app|pages|widgets|features|entities|shared)\/[^\/]+\/.+\"$",
429+
register_diagnostic(
430+
span = $src,
431+
message = "Only 2 level paths are allowed (e.g. @layer/name).",
432+
severity = "error"
433+
)
434+
}
435+
}"#,
436+
);
437+
fs.insert(
438+
"tools/biome/plugins/fsd-deps.grit".into(),
439+
br#"engine biome(1.0)
440+
language js(typescript,jsx)
441+
442+
sequential {
443+
`import $w from $src` where {
444+
$filename <: r".*/pages/.*",
445+
$src <: r"^\"@app(?:/.*)?\"$",
446+
register_diagnostic(
447+
span = $src,
448+
message = "pages cannot import from higher layer @app.",
449+
severity = "error"
450+
)
451+
},
452+
453+
`import $w from $src` where {
454+
$filename <: r".*/widgets/.*",
455+
$src <: r"^\"@(pages|app)(?:/.*)?\"$",
456+
register_diagnostic(
457+
span = $src,
458+
message = "widgets cannot import from @pages or @app.",
459+
severity = "error"
460+
)
461+
},
462+
463+
`import $w from $src` where {
464+
$filename <: r".*/features/.*",
465+
$src <: r"^\"@(widgets|pages|app)(?:/.*)?\"$",
466+
register_diagnostic(
467+
span = $src,
468+
message = "features cannot import from @widgets, @pages, or @app.",
469+
severity = "error"
470+
)
471+
},
472+
473+
`import $w from $src` where {
474+
$filename <: r".*/entities/.*",
475+
$src <: r"^\"@(features|widgets|pages|app)(?:/.*)?\"$",
476+
register_diagnostic(
477+
span = $src,
478+
message = "entities cannot import from higher layers.",
479+
severity = "error"
480+
)
481+
},
482+
483+
`import $w from $src` where {
484+
$filename <: r".*/shared/.*",
485+
$src <: r"^\"@(entities|features|widgets|pages|app)(?:/.*)?\"$",
486+
register_diagnostic(
487+
span = $src,
488+
message = "shared cannot import from higher layers.",
489+
severity = "error"
490+
)
491+
},
492+
493+
`import $src` where {
494+
$filename <: r".*/shared/.*",
495+
$src <: r"^\"@(entities|features|widgets|pages|app)(?:/.*)?\"$",
496+
register_diagnostic(
497+
span = $src,
498+
message = "shared cannot import from higher layers (side-effect import).",
499+
severity = "error"
500+
)
501+
}
502+
}"#,
503+
);
504+
fs.insert("src/pages/a.ts".into(), br#"import "@app/foo";"#);
505+
506+
let _ = run_cli_with_server_workspace(fs, &mut console, Args::from(["check", "."].as_slice()));
507+
508+
assert!(
509+
!console
510+
.out_buffer
511+
.iter()
512+
.flat_map(|message| &message.content.0)
513+
.any(|node| node.content.contains("processing panicked")),
514+
"Grit plugin processing panicked: {:?}",
515+
console.out_buffer
516+
);
517+
}

‎crates/biome_cli/tests/cases/reporter_github.rs‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::run_cli;
2-
use crate::snap_test::{SnapshotPayload, assert_cli_snapshot};
1+
use crate::snap_test::{SnapshotPayload, assert_cli_snapshot, message_to_string};
2+
use crate::{run_cli, run_cli_with_dyn_fs};
33
use biome_console::BufferConsole;
4-
use biome_fs::MemoryFileSystem;
4+
use biome_fs::{MemoryFileSystem, TemporaryFs};
55
use bpaf::Args;
66
use camino::Utf8Path;
77

@@ -168,3 +168,39 @@ fn reports_diagnostics_github_format_command() {
168168
result,
169169
));
170170
}
171+
172+
#[test]
173+
fn reports_diagnostics_github_from_nested_directory() {
174+
let mut fs = TemporaryFs::new("reports_diagnostics_github_from_nested_directory");
175+
let mut console = BufferConsole::default();
176+
177+
fs.create_file("packages/ui/main.ts", "debugger;\n");
178+
fs.append_to_working_directory("packages/ui");
179+
180+
let result = run_cli_with_dyn_fs(
181+
Box::new(fs.create_os()),
182+
&mut console,
183+
Args::from(["lint", "--reporter=github", fs.cli_path()].as_slice()),
184+
);
185+
186+
assert!(result.is_err(), "run_cli returned {result:?}");
187+
188+
let output = console
189+
.out_buffer
190+
.iter()
191+
.map(message_to_string)
192+
.collect::<String>()
193+
.replace('\\', "/");
194+
assert!(
195+
output.contains("/packages/ui/main.ts"),
196+
"unexpected output: {output}"
197+
);
198+
199+
assert_cli_snapshot(SnapshotPayload::new(
200+
module_path!(),
201+
"reports_diagnostics_github_from_nested_directory",
202+
fs.create_mem(),
203+
console,
204+
result,
205+
));
206+
}

0 commit comments

Comments
 (0)