Skip to content

Auto fix with Astro deletes source code when formatting #894

@grundmanise

Description

@grundmanise

VS Code version

1.105.1

Extension version

3.3.0

Biome version

2.3.8

Operating system

  • Windows
  • macOS
  • Linux

Description

I'd like to report an issue with Astro formatter. When assist/source/organizeImports is enabled and autofix is applied, all the code between --- gets deleted except for the (now) sorted imports.

Before fix:

---
import Card from "./card.astro";
import { className } from "solid-js/web";

console.log('FOO')
// more JS
---
// HTML

After fix:

---
import { className } from "solid-js/web";
import Card from "./card.astro";
---
// HTML

settings.json:

...
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "emmet.showExpandedAbbreviation": "never",
  "editor.codeActionsOnSave": {
    "source.organizeImports.biome": "explicit",
    "source.addMissingImports": "explicit",
    "source.fixAll.biome": "explicit"
  }
...

biome.jsonc:

  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on"
      }
    }
  },

Steps to reproduce

Apply a similar config in the Astro project. Use the VSCode plugin to fix import sorting.

Expected behavior

Imports will be sorted and code fixed.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Link to a minimal reproduction

No response

Logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions