Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ranking Biome vs. ESLint #5

Open
frytg opened this issue Apr 13, 2024 · 11 comments
Open

Ranking Biome vs. ESLint #5

frytg opened this issue Apr 13, 2024 · 11 comments

Comments

@frytg
Copy link

frytg commented Apr 13, 2024

Is there any configuration needed to make sure Zed is prefering Biome over native ESLint?

When I install the extension (v0.0.2) in Zed Preview (v0.131.4), it creates a different formatting output in JS files vs. the Biome CLI. It seems like it is doing something when saving (adjusting spaces or so), but that seems to be more the output from ESLint or some other language server.
Actually running bunx biome format index.js --write however reformats the whole file (replaces spaces with tabs, which also seems to be the default) - which would be the intended way.

Is there any other way to debug or improve this?

This is in settings.json:

"format_on_save": "on",
"code_actions_on_format": {
    "source.fixAll": true,
    "source.organizeImports.biome": true
},
"formatter": "language_server"

Adding a biome.json with some arbitrary values like formatter.indentWidth: 16 also shows that it doesn't get picked up, while the CLI replaces that.

@luckydye
Copy link
Collaborator

There is currently no way to disable eslint in zed, I think. It is baked into the typescript extension which is builtin. So if both is configured, they may be conflicting.

One limitation is currently, that the biome.json needs to sit in the root of the zed project to be seen by the biome language server.

You can also try to set source.fixAll.biome instead, so it wont apply fixes from other language servers.

Can you provide a repo for reproduction?

@frytg
Copy link
Author

frytg commented Apr 14, 2024

Thanks for the quick feedback!
I was able to see the Biome logs and verify that it properly picks up the config, but it seems that Zed is doing some interesting processing or doesn't properly trigger formatting. I'll create a repo to reproduce this issue this coming week.

@maxdeviant
Copy link
Contributor

maxdeviant commented Apr 23, 2024

There is currently no way to disable eslint in zed, I think. It is baked into the typescript extension which is builtin. So if both is configured, they may be conflicting.

I'm currently working on a fix for this (tracked by zed-industries/zed#10906).

I just landed zed-industries/zed#10911 to main which will allow you to add this to your settings to disable the built-in TypeScript and ESLint language servers in favor of Biome:

{
  "languages": {
    "TypeScript": {
      "language_servers": ["biome", "!typescript-language-server", "!eslint", "..."]
    }
  }
}

Will be shipping to Preview tomorrow.

@luckydye
Copy link
Collaborator

Thats great! Though the biome lsp server should be used together with the ts-server, not instead. But we can finally disable eslint! ^^

@maxdeviant
Copy link
Contributor

maxdeviant commented Apr 24, 2024

Thats great! Though the biome lsp server should be used together with the ts-server, not instead. But we can finally disable eslint! ^^

Oh, for some reason I thought Biome had its own TS language server 😄

But yes, it can be used to disable ESLint!

@frytg
Copy link
Author

frytg commented Apr 24, 2024

Oh wow, that looks really promising, @maxdeviant and would probably solve the ranking issue with clashes of eslint vs. Biome!
I'll keep an eye on the Preview version.

@frytg
Copy link
Author

frytg commented Apr 27, 2024

Hi @maxdeviant and @luckydye, I create this repository to demonstrate my use-case and errors: https://github.com/frytg/biome-zed-repro-temp

I hope this makes sense. I hope I didn't do any super dumb mistakes, which prevents this whole setup, but so far it seems quite hard and complicated to get Biome working in Zed.

@luckydye
Copy link
Collaborator

@frytg awsome! I agree it should be very easy.

@luckydye
Copy link
Collaborator

luckydye commented Apr 27, 2024

So the problem is, zed thinks the biome language server doesn't have the capability to run "textDocument/formatting", which is odd, cause it does.

I have a fix here: https://github.com/luckydye/zed/tree/biome-formatting-fix, but I think this would ignore any other language server that could format but is not the first priority.

Thats as far as I got for now...

Update: TLDR, formatting doesn't work because zed does not support dynamic register for formatting capabilities.

@muuvmuuv
Copy link

Is there an upstream issue for dynamic register of formatting caps?

@ematipico
Copy link
Member

We removed dynamic registration of formatting capabilities because not all clients support it.

Also, you can't have static and dynamic registration of the same capabilities, some clients like VSCode break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants