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.19k stars 439 forks source link

`organizeImports` Formatting exceptions in the `vscode` editor #1549

Closed ayangweb closed 7 months ago

ayangweb commented 8 months ago

Environment information

CLI:
  Version:                      1.5.1
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v16.14.2"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/8.5.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Configuration

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

Playground link

https://github-production-user-asset-6210df.s3.amazonaws.com/75017711/296443468-d8caa8c1-4f1e-4474-a179-975e3e03382e.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240113%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240113T095543Z&X-Amz-Expires=300&X-Amz-Signature=6e789973a83e527615cb1f0df74345e7f97bd6a7612c67a6c6a26818ab9aeb53&X-Amz-SignedHeaders=host&actor_id=75017711&key_id=0&repo_id=611734759

Code of Conduct

ayangweb commented 8 months ago

Restarting vscode works, but after a while it still throws an exception!

mirumirumi commented 8 months ago

I have a same problem...

  Version:                      1.5.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.9.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.1.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0
ematipico commented 8 months ago

Can someone share a reproduction? Github repository, codesandbox or playground

roderik commented 8 months ago

I cannot share a reproduction, because according to my anecdotal evidence it is not config or code related. The way I experience it, it is like a race condition, or running simultaneous, applying the same changed over/into each other.

If it happens and i ctrl-z back to the correct state and save again, it often works fine.

I'm from the time saving was wonky, so i know i do press ctrl-s s s s s s s s s when i want to save, but it even happens in other cases when i'm sure i save just once. So potentially an interplay with other VS Code features/plugins?

I've got no experience with vs code plugins, but i assume there is a way to get a "lock" on a file to apply changes to it in some way?

JUSTIVE commented 8 months ago

I am experiencing a similar issue. I have set 'organizeImports: true' in biome.json and enabled 'format on save.' However, the formatting and organizing often result in a mixed and invalid state. This issue doesn't occur every time, but it can generally be resolved by reloading and waiting for a short while.

mirumirumi commented 8 months ago

@ematipico

Can someone share a reproduction? Github repository, codesandbox or playground

Yes, I would like to support biome and offer reproduction, but I don't have time right now. I will work on reproduction when I have time. I don't want to go back to prettier because of this...

nhedger commented 8 months ago

Wondering if there could be a race condition that provokes this issue.

ematipico commented 7 months ago

@ayangweb do you still experience the issue with 1.5.3? Make sure to close and open VSCode.

ayangweb commented 7 months ago

@ayangweb do you still experience the issue with 1.5.3? Make sure to close and open VSCode.

Ok, I'll download it and try it, this is also an occasional bug that I haven't encountered in 1.5.1 for a while!

mirumirumi commented 7 months ago

@ematipico

@ayangweb do you still experience the issue with 1.5.3? Make sure to close and open VSCode.

Yes! It is fixed! Thank you very much! :heart: