biome-vscode: Extension "Biome" is configured as formatter but it cannot format 'TypeScript JSX'-files
VS Code version
1.93.1
Extension version
2024.9.200949
Biome version
1.9.2
Operating system
- Windows
- macOS
- Linux
Description
Updated Biome from 1.8.3 and VS Code extension to pre-release for better support of workspaces. We currently use a workaround in PlatformPlatform
Steps to reproduce
- Clone PlatformPlatform
- Update settings for the new VS Code extension:
"biome.enabled": true,
"biome.lsp.trace.server": "verbose",
"biome.lsp.bin": "application/node_modules/.bin/biome",
"biome.projects": [
{
"folder": "application",
"path": "application",
"configFile": "biome.json"
}
],
"biome.requireConfigFile": true
- Update the Biome version in
application/package.json - Change the formatting / indention in one of the
tsxfiles - Right click and choose “format document”
See:
Expected behavior
The document should re format as the CLI tool would do e.g. npm run format
Does this issue occur when using the CLI directly?
No
Link to a minimal reproduction
https://github.com/platformplatform/PlatformPlatform
Logs
2024-09-30 21:23:40.701 [info] Biome extension 2024.9.200949 activated
2024-09-30 21:23:40.701 [info] Biome extension started
2024-09-30 21:23:40.701 [info] User-facing commands registered
2024-09-30 21:23:40.701 [info] Started listening for lockfile changes
2024-09-30 21:23:40.701 [info] Started listening for configuration changes
2024-09-30 21:23:40.701 [info] Started listening for active text editor changes
---
npx biome rage --daemon-logs
CLI:
Version: 1.9.2
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
NO_COLOR: unset
TERM: "xterm-256color"
JS_RUNTIME_VERSION: "v22.8.0"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "npm/10.8.2"
Biome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: true
VCS disabled: false
Workspace:
Open Documents: 0
Discovering running Biome servers...
Incompatible Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Rage discovered this running server using an incompatible version of Biome.
Server:
Version: 1.8.1
Server:
Status: stopped
Incompatible Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Rage discovered this running server using an incompatible version of Biome.
Server:
Version: 1.8.2
Incompatible Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Rage discovered this running server using an incompatible version of Biome.
Server:
Version: 1.8.3
Incompatible Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Rage discovered this running server using an incompatible version of Biome.
Server:
Version: 1.9.1
Incompatible Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Rage discovered this running server using an incompatible version of Biome.
Server:
Version: 1.9.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 31 (11 by maintainers)
Commits related to this issue
- Minimal reproduction ref: https://github.com/biomejs/biome-vscode/issues/373 — committed to raix/biome-repro-1727796280038 by raix 2 years ago
in my case the problem was solved after deleting the socket file(s) from here (macos only):
/Users/[username]/Library/Caches/dev.biomejs.biomeNew release
I’ve released a new pre-release version, which I believe fixes this issue.
What happened
When the extension generates a document selector to filter which document should be taken into account by a given LSP session, it uses the
pathspecified in the configuration and appends a glob pattern to it.When the
pathcontains a trailing/, the glob pattern is valid, but if the path does not contain the trailing/, the glob pattern is invalid, which causes VS Code to say that Biome cannot format the file, as it is ignored.https://github.com/biomejs/biome-vscode/blob/becbd5a4d05d3edd00d074607c063a6edfa1f976/src/session.ts#L350-L354
Fix
I’m now joining all path elements using
Uri, which should gracefully handle all sorts of quirks such as missing or duplicate trailing/.https://github.com/biomejs/biome-vscode/blob/f9aa11226fd6a940f8dcbf0cb2ac951f894983b7/src/session.ts#L350-L357
There was an issue with how the document selector glob was created under windows.
Commit b583860532d38ddbd16914d20ce612c41c9dec4e should fix it.
You may try the latest pre-release. In the meantime, I’m going to close this issue.
If you encounter a similar issue, please open a dedicated issue with a minimal reproduction.
^^^ It works after specifying
"biome.lspBin": "node_modules/.bin/biome"in the workspace settingsI experience this error with all the setups on various Windows computers. I do not have Macs. So, I tried to install VSCode Insiders and pre-relase version of Biome extension. I tried various project as well as Minimal reproduction setup with latest pre-release of the extension. I tried without biome.json, default biome.json, various modifications (include the folder), but nothing helped. Of course, I have biome as default formatter in global VSCode settings.
Version: 1.97.0-insider (user setup) Commit: 31188fed068c5c724d73a1956c846401d4d7b01d Date: 2025-01-16T05:07:10.789Z Electron: 32.2.7 ElectronBuildId: 10660205 Chromium: 128.0.6613.186 Node.js: 20.18.1 V8: 12.8.374.38-electron.0 OS: Windows_NT x64 10.0.26100
package.json “devDependencies”: { “@biomejs/biome”: “1.9.5-nightly.ff02a0b” }
settings.json { “editor.defaultFormatter”: “biomejs.biome” }
All the setups do show this issue bug only and always on files (*.js, *.ts, *.json) that are deeper than one folder from root. For example:
src\index.tsorsrcb\index.tswork.src\inner\test.jsorsrcb\inner\test.tsdo not work. The error that shows in right down corner is: FormattingExtension ‘Biome’ is configured as formatter but it cannot format ‘JavaScript’-files or ‘TypeScript’ and biome also does not show in dialog for selecting default formatter.the content of the files is:
let a = 2so it should show some errors and try to format.Oh, interesting. I would also have expected that config file to be resolved relative to the path. I’ll look into this.
@nhedger if I remove the “folder” setting I get:
I believe I’ve found the issue. I’ll patch it this morning and release a new pre-release. I’ll also update this issue with an explanation.
@ematipico I’ve created and pushed a Minimal reproduction using your CLI tool
Thank you, @raix, for the report. However, we would appreciate it if you could create a minimal reproduction instead of providing a massive repository. A minimal reproduction would remove possible user/environment options that could tarnish the project.
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