biome-vscode: šŸ› Biome doesn't format on save

VS Code version

1.90.0

Extension version

2.3.0

Biome version

1.8.0

Operating system

  • Windows
  • macOS
  • Linux

Description

As title says, biome won’t format codes in vscode when Ctrl + S. Ctrl + Shift + P > Format Document... will correctly format.

Steps to reproduce

  1. Just Ctrl + S

Expected behavior

Biome will format codes when Ctrl + S

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Logs

outputs from VS Code Biome

Biome binary found at s:\workspace\konomi-hp\node_modules\.pnpm\@biomejs+cli-win32-x64@1.8.0\node_modules\@biomejs\cli-win32-x64\biome.exe
Copying binary to temporary folder: file:///c%3A/Users/rikusen/AppData/Roaming/Code/User/workspaceStorage/a651e6ef88d0cffc954257946c90e77a/biomejs.biome/biome.exe
Executing Biome from: c:\Users\rikusen\AppData\Roaming\Code\User\workspaceStorage\a651e6ef88d0cffc954257946c90e77a\biomejs.biome\biome.exe
[cli-stdout] data 29
[cli] exit 0
Connecting to "\\.\pipe\biome-service-1.8.0" ...
[Info  - 21:10:29] Server initialized with PID: 35248

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 40 (9 by maintainers)

Most upvoted comments

@ematipico I guess I set VSCode completely 😦 Here is the config:

{
  "editor.defaultFormatter": "biomejs.biome",
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "editor.codeActionsOnSave": {
    "quickfix.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
}

Kind of off topic and a couple days too late but seeing all these configs around here I just though I’d share that this right here works so you don’t have to add multiple lines with the same setting for each language:

{
  "[json][javascript][javascriptreact][typescript][typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  }
}

Woot! After some hours trying everything around, in my case, I just found some options that after deactivated them, my Biome just back to work like a charm.

I’ll let this information here if someone having the same issue at windows.

I just migrated those eslint+prettier configurations to Biome json file and deactivated these two options in my VsCode settings (those both were activated for some reason): configs

Same here. But mine doesn’t work even with ā€œFormat Documentā€¦ā€. I have to run CLI (npx @biomejs/biome format --write <files>) to format the files correctly. And my Settings at VsCode are configured.

ā€œeditor.formatOnSaveā€: true, ā€œeditor.defaultFormatterā€: ā€œbiomejs.biomeā€,

I think I figured out why this is happening. The issue lies in how language selectors are implemented differently between formatters:

Prettier’s VSCode extension has special handling for comma-separated language selectors in settings.json, automatically splitting them into separate configurations internally. For example, this works with Prettier:

"[typescript, typescriptreact, json]": {
  "editor.formatOnSave": true
}

However, Biome strictly follows VSCode’s native language selector syntax, which requires separate configuration blocks for each language. The correct way for Biome would be:

"[typescript]": {
  "editor.formatOnSave": true
},
"[typescriptreact]": {
  "editor.formatOnSave": true
},
"[json]": {
  "editor.formatOnSave": true
}

It is ā€œnot a bugā€, but I wonder if Biome also adopt comma version of language selector can make configuration a bit less painful?

@ematipico I find it ! Because there is in settings.json:

  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

BUT! cmd + , does not show this configuration 😭 This should be a vscode bug.

@rikusen0335 Unfortunately, I cannot reproduce the issue with the provided repository. As @ematipico suggested, there may be a global setting in your VS Code profile that sets another tool as the default formatter for these files.

You can try overriding this by creating a .vscode/settings.json file with the following contents:

{
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
}

Just to add my solution to this. I had to pull up the settings.json (not the UI but the actual json file) and do a text search for all instances of editor.defaultFormatter for the related languages and remove them. Seems like they aren’t removed when prettier is uninstalled.

If you’ve tried most of the things above and still no luck this should hopefully help you debug further:

CTRL + SHIFT + P Format Document (in pop-up bar) Select Format Document

I did all of those things, as well as manually write the settings in json file. Then I started using Deno, and it already has its own formatter built in, but it also refused to format when saving the document, until I completely removed the Biome extension from VS Code.

I have been having issues on two separate macs with biome format on save actions for the past 1-2 months. Before this, it was working a treat.

Removing the files within /Users/<UserName>/Library/Caches/dev.biomejs.biome as mentioned on https://biomejs.dev/guides/integrate-in-editor/#daemon-logs resolved my issue.

The files removed included:

biome-logs
biome-socket-1.6.4
biome-socket-1.7.0
biome-socket-1.7.1
biome-socket-1.7.2
biome-socket-1.7.3
biome-socket-1.8.0
biome-socket-1.8.1
biome-socket-1.8.2
biome-socket-1.8.3

Yeah of course, I will make a minimal reproduction tomorrow