biomejs / biome-vscode

Biome extension for Visual Studio Code and VSCodium
https://marketplace.visualstudio.com/items?itemName=biomejs.biome
Apache License 2.0
221 stars 30 forks source link

🐛 Unable to use Biome format outside of a workspace with a biome.json file #387

Open baptisteArno opened 1 week ago

baptisteArno commented 1 week ago

VS Code version

1.95.0

Extension version

2024.10.40751

Biome version

Can't find it

Operating system

Description

Whenever I try to format a standalone file (tried with json and js), it says

Extension 'Biome' is configured as formatter but it cannot format 'JavaScript'-files

Here are my user settings:

"editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[javascriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[json]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[css]": {
    "editor.defaultFormatter": "biomejs.biome"
  }

Steps to reproduce

I guess just open a standalone file that is not part of a project that has biome installed

Expected behavior

To format docs

Does this issue occur when using the CLI directly?

No

Link to a minimal reproduction

No response

Logs

No response

ematipico commented 1 week ago

Please provide a minimal reproduction @baptisteArno

baptisteArno commented 1 week ago

https://github.com/user-attachments/assets/30f01b0a-d25e-47dd-9fb4-93f1dd303890

ematipico commented 1 week ago

Sorry @baptisteArno, but this isn't a reproduction. We need a reproduction so we can reproduce the issue and debug it.

To create a reproduction, you can use our new CLI tool, which should help you to create a very quick repository with what you need: npm create @biomejs/biome-reproduction

ematipico commented 1 week ago

As you can notice from the video, the extension didn't enable Biome because the event enables and spawns the Biome server wasn't triggered. When Biome is enabled, you should see Biome in the bottom left. This is expected (maybe things have changed in the preview release).

baptisteArno commented 1 week ago

Correct me if I am wrong but I don't think I can create a code reproduction for that particular issue since it is not tied to a specific workspace / biome setting. To reproduce it, we even need the biome.json file not to be there. It just needs plain VSCode Insiders + Biome pre-release to reproduce it.

Sometimes, a reproduction is just a step-by-step instructions

  1. In VSCode Insiders, install Biome extension
  2. Create new file with the following content console.log("Hello world")
  3. Biome is not enabled even though the file was autodetected as Javscript and even if we specific the Javascript file type, Biome does not launch
ematipico commented 1 week ago

Thank you. The step-by-step instructions are also a valid reproduction. This information should have been present in the initial description.