Comments (31)
@ematipico here's a simple reproduction showing the issue I'm having (maybe not related?):
Before save (swapped imports to be out of order)
After save
fwiw I also just tried disabling source.addMissingImports
and got the same result, so this seems like a bug isolated to source.organizeImports.biome
. Update: interestingly restarting VSCode or resetting the extension host seems to fix things temporarily, so the example above works again until it starts breaking and then I can reproduce it consistently until I restart again. Maybe there's some sort of corrupted internal state of either VSCode or the extension?
from biome.
We just published a nightly with a possible fix: https://github.com/biomejs/biome/releases/tag/cli/v1.5.2-nightly.91c7730
It would be great if someone can try it, and let us know.
from biome.
Yeah I don't think the issue caused by multiple instances are fixed. And there're still failing cases that I'm aware of even there is only one instance. This is a complex issue, but we'll fix it step by step.
from biome.
I have also been experiencing this issue. It seems to be because there is many Biome agents running and happens if I have left my Mac on overnight. If I hover over a Biome warning or error I can see the error repeated, sometimes 20 times.
Closing VSCode completely does fix the issue and Biome suggestions are no longer duplicated.
So I would suggest the issue is with Biome seemingly restarting without killing the previous process for some reason?
from biome.
Still a problem on 1.5.3
from biome.
And just like that, I finally witnessed the imports being messed up with my own eyes too! I'd been keeping the session with 4 Biome entries open, and it further reinforces my suspicion of the mangled imports and duplicate formatter entries being related: The mangled imports I witnessed had one of the imports being repeated 4 times:
One thing of note though, this didn't happen to me on Save or by manually using Organize Imports. It happened when I renamed a symbol in one file and VS Code applied the refactoring to update that symbol in another file. Maybe that somehow triggered all four formatters to kick in, causing the renamed symbol to appear 4 times.
from biome.
Just did little refactoring, removing and shuffling around code and so far it worked flawlessly π But that was only about 15 minutes of coding, I'll report if anything else pops up.
from biome.
Seems to be problematic in this case too:
import { d } from '@dd';
import { a } from '@a';
import { b } from '@b';
But not in this:
import { d } from 'dd';
import { a } from '@a';
import { b } from '@b';
The @ symbol seems to be the reason here.
from biome.
Can you share a playground link?
from biome.
I can't repro on playground, just vscode
from biome.
Then you'll have to share a reproduction. This will help us to identify the issue
from biome.
source.organizeImports.biome
breaks for me in VSCode constantly. It sometimes eats multiple lines of code and then spits out repeated import lines probably due to competing with source.addMissingImports
? I've had to disable source.organizeImports.biome
entirely since I just can't get it to work consistently without breaking code.
I don't have a working reproduction offhand since it seems to have to do with combination of quickfix.biome
, source.organizeImports.biome
, and source.addMissingImports
, but will try to replicate it next time I see it.
from biome.
Sorry @kainosnoema , this isn't a reproduction.
We need to be able to reproduce the issue. A repository would be great.
Without that , we can't help.
from biome.
Iβll try enabling source.organizeImports.biome
in my setup, see if I run into it.
from biome.
Yeah, same issue here. It randomly happens as well. Reloading VSCode works. Sometimes the imports completely disappears, sometimes it completely changes
from biome.
I wonder to what extent this issue and #1584 are related. I'm getting the impression both situations may be caused by having too many daemons running.
As far as I see, I also only see Mac users in these threads. So if there's a non-Mac user experiencing this, please raise your voice, since it might help us figure out in which direction to look.
from biome.
Hasn't happened to me since 1.5.2-dev and 1.5.3 π€
from biome.
I'm not sure how or why... but disabling reenabling plugin seemed to work afterwards... I'll keep you posted
from biome.
Thank you all for confirming.
For anyone coming here , to apply the fix you must restart your VSCode after updating to Biome 1.5.3. There was an issue in the LSP.
from biome.
Today I heard reports from several co-workers that seem to be running into this issue still, all on 1.5.3. Unfortunately, I haven't been able to witness it myself, but I did notice just now that I had 4 Biome formatter entries in VS Code, which was also one of the things my co-workers witnessed.
So while #1590 seems to have fixed #1584 (the issue that two Biome formatter entries appear in VS Code right away), I think there is still a lurking issue that causes additional entries to be registered over time. And my assumption here is that once there are multiple entries, they can still conflict and trigger this behavior.
I'm afraid I still have no additional information what might be the root cause however :(
from biome.
Okay, and now that it happened once, if I use Undo to revert to how the imports were before they got mangled, then hit Save (I have Organize Imports enabled on Save) it mangles it again.
Update: One more piece of information: If I invoke Organize Imports explicitly, I get to choose between 5 entries. I think one is VS Code's native Organize Imports, while the other 4 are marked as Biome:
I can select any of those 5 entries, and the imports get organized as expected. So the functionality itself is fine. But I hit Save, and it mangles again, presumably because multiple get invoked at the same time.
Update: If I reorder imports in another file and Save, it also mangles there. So somehow I've gotten into a state now where it will always mangle if I Save while there are imports that need sorting. Saving files where the imports are already sorted is still fine.
from biome.
Is it possible that you enabled the rule https://biomejs.dev/linter/rules/use-import-type/ ?
from biome.
It shouldn't be, no...
from biome.
I've got very similar issues, when organizing imports on save. Iβm using subpath imports, basically import aliases that start with #
. Also I have noUnusedImports
on, might make the issue worse.
Here it removes a wrong import:
Screen.Recording.2024-03-12.at.17.07.03.mov
Here React
is not removed properly:
Screen.Recording.2024-03-13.at.09.25.28.mov
Here React
is added twice and the last import it messed up:
Screen.Recording.2024-03-13.at.10.12.57.mov
This issue #1015 suggested using config like below, it did help at first but has since gotten worse, maybe after updating to 1.6.2, not sure.
{
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
}
}
Any tips for the VSCode config?
Would an umbrella issue be helpful? There seems to be quite a bit of report relating to this.
from biome.
Also I have noUnusedImports on, might make the issue worse.
I noticed that some of the bugs reported are caused by this very rule.
from biome.
Can anyone confirm whether the failing cases in this issue can still be reproducible in the latest version (v1.6.4)?
from biome.
Just messed up my imports π
Had 2 biome instances on version 1.6.4
from biome.
I just want to say you guys are the best, eslint is happily far in the rear view mirror and it's hard to imagine things were any different. Just need that pesky no-hanging-promises and this will be literally perfection in both how it's written and its application.
from biome.
First import sorting issue since updating to 1.6.4. It might have something to do with the automatic fixing of the double quotes. If I cmd+z the last fix and then save again it's fixed.
In general itβs been working so much better! Thanks for fixing it.
Screen.Recording.2024-04-06.at.08.48.29.mov
from biome.
After initially enabling the "source.organizeImports.biome": "explicit"
I was getting shuffled and random imports. They were overlapping with one another, and there were also duplicates.
Doing "undo" and formatting again, worked OK.
What fixed it for now was restarting VS Code as some of the previous comments have mentioned.
from biome.
Looks like this issue is a bit broader and applies to lint rule fixes too: biomejs/biome-vscode#241
I can consistenlty reproduce the issue with the linked example, so hopefully this will help debug it.
And I only have one instance of Biome LSP running.
from biome.
Related Issues (20)
- π Override behavior with multiple matches HOT 1
- π Import sorter revamping - custom order
- βοΈ Analyzer assists HOT 3
- π `npx @biomejs/biome migrate` command crashes HOT 5
- π CSS formatter converts custom identifiers to lowercase HOT 3
- βοΈ Type-aware linter
- π CSS extra whitespace added within `:has`
- π Pin bench libs
- useExhaustiveDependencies ignore comment does not work if methods called on the dependency HOT 4
- Position not provided with `--stdin-file-path` HOT 2
- π `noUndeclaredDependencies` checks root `package.json` in monorepo workspaces HOT 2
- Path with brackets in it causes `internalError/io` on Windows environment HOT 6
- π `useExhaustiveDependencies` error's when (adding and not adding) to array HOT 3
- π My vscode doesn't format itself when I save HOT 3
- π useExhaustiveDependencies complains about not including React component in dependency array
- π Request textDocument/formatting failed HOT 1
- π Biome cannot handle JSON formatting but Prettier can HOT 6
- Reformat issue with css formatter
- π biome ci . --colors=off outputting colors HOT 5
- π `lint/suspicious/noFallthroughSwitchClause` warns about a missing `break` even if TypeScript considers it unreachable due `never`. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biome.