biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
14.54k stars 455 forks source link

Autofix on save leaves empty import #2668

Open OliverJAsh opened 5 months ago

OliverJAsh commented 5 months ago

VS Code version

1.88.1

Extension version

2.2.2

Biome version

1.7.2

Operating system

Description

When noUnusedImports is enabled, autofix on save leaves an empty import.

Steps to reproduce

Given:

biome.json:

{
    "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
    "linter": {
      "enabled": true,
      "rules": {
        "correctness": {
          "noUnusedImports": "warn"
        }
      }
    }
  }

.vscode/settings.json:

{
    "editor.codeActionsOnSave": {
      "quickfix.biome": "explicit"
    }
  }

index.ts:

import { A, B } from 'foo';

// edit this comment and save the file

When I save index.ts and the autofix runs, I end up with an empty import:

import {} from 'foo';

Expected behavior

Import is removed.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

No response

samhh commented 4 months ago

If it helps narrow the issue down, I can't repro this with biome lint --apply. The import statement is fully removed. I also can't repro with code actions in my editor (not VS Code), however I'm applying them manually.

krismarv commented 1 month ago

I have the same issue and the empty import is not removed on save, with biome lint --apply or with biome check --fix. VS Code 1.92.2, Biome extension 2.3.0, Biome 1.8.3, macOS