biomejs/biome

Formatter instability with same line comments and array holes

Opened this issue · 0 comments

As obscure as it is, it seems like this causes issues in the formatter

[
  , /* this */
]

In particular it seems like the formatting isn't stable? Putting this in the quick_test.rs gives me:

---- quick_test stdout ----
[
  "[",
  group("#array-1", [
    indent([soft_line_break, group([" /* this */"]), ","]),
    soft_line_break
  ]),
  "];",
  hard_line_break
]
[ /* this */,];

Differences (-input|+output):
 [
   "[",
   group("#array-1", [
-    indent([soft_line_break, group(["/* this */ "]), ","]),
+    indent([soft_line_break, group([" /* this */"]), ","]),
     soft_line_break
   ]),
   "];",
   hard_line_break

thread 'quick_test' panicked at /Users/davis/files/programming/biome/crates/biome_formatter_test/src/check_reformat.rs:100:13:
assertion failed: `(left == right)`'
  left: `"[ /* this */,];\n"`
 right: `"[/* this */ ,];\n"`

Differences (-left|+right):
-[ /* this */,];
+[/* this */ ,];

Environment information

I was actually using the dev version, built from scratch locally

Configuration

No response

Playground link

https://biomejs.dev/playground/?code=WwAKACAAIAAsACAALwAqACAAdABoAGkAcwAgACoALwAKAF0A

Code of Conduct

  • I agree to follow Biome's Code of Conduct