Skip to content

🐛 Astro with "fixAll.biome" option only leaves frontmatter after format #6528

@oddmouse

Description

@oddmouse

VS Code version

1.101.14098

Extension version

3.0.3

Biome version

2.0.5

Operating system

  • Windows
  • macOS
  • Linux

Description

Since upgrading Biome to version 2.0.0, formatting on save with .astro files completely removes all code that is not inside frontmatter.

When running pnpm biome check --fix src/test.astro in the terminal, everything runs as expected.

The only thing I could find related to this is an issue with the Zed extension where I am also experiencing the issue. biomejs/biome-zed#60

Steps to reproduce

  1. Clone the MRE repo
  2. Open src/test.astro in VS Code with the biome extension installed
  3. Save the file and watch it format and strip out all code except for the frontmatter

From this:

---
const useSortedKeys = {
  2: "two",
  3: "three",
  1: "one",
  4: "four",
};

let useConst = "Astro Test";
---

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{useConst}</title>
  </head>
  <body>
    <h1>{useConst}</h1>
    <ol>
      {Object.values(useSortedKeys).map((val) => <li>{val}</li>)}
    </ol>
  </body>
</html>

To this:

const useSortedKeys = {
  1: "one",
  2: "two",
  3: "three",
  4: "four",
};

const useConst = "Astro Test";

Expected behavior

The formatting is expected to be the same as when running pnpm biome check --fix src/test.astro:

---
const useSortedKeys = {
  1: "one",
  2: "two",
  3: "three",
  4: "four",
};

const useConst = "Astro Test";
---

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{useConst}</title>
  </head>
  <body>
    <h1>{useConst}</h1>
    <ol>
      {Object.values(useSortedKeys).map((val) => <li>{val}</li>)}
    </ol>
  </body>
</html>

Does this issue occur when using the CLI directly?

No

Link to a minimal reproduction

https://github.com/oddmouse/biome-astro-format-on-save-mre

Logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CoreArea: coreS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy