When use "organize imports", same folder imports are deleted
See original GitHub issueDescribe the bug
When I do right click -> Source Action... -> Organize Imports
or also using the shortcut associated alt + shift + o
, all my local imports disappear, whatever if I use them or not.
Then, of course, VSCode is full of colours like a Xmas tree…
Reproduction
- Create 3-4 components with simple slots, in the same
$lib
sub-folder. - Create index files (JS and TS) to export them from that folder.
- In one of these components, create a hierarchy (one component inside another, for the slot), by using language tool imports on auto-completion.
- Auto-completion should have created one import line for each component.
- Trigger
Organize Imports
- No more imports…
Code example :
<script lang="ts">
import { ComponentA } from '.';
import { ComponentB } from '.';
import { ComponentC } from '.';
</script>
<ComponentA>
<ComponentB>
<ComponentC/>
</ComponentB>
</ComponentA>
From what I noticed, it’s only with local imports, and only when the script tag contains only local imports.
Expected behaviour
Imports still in use shouldn’t disappear, and should be merged in only one import line.
System Info
- OS:
Xubuntu 22.04
- IDE:
VSCode 1.67.0
, usingSvelte for VS Code
Everything is up to date, VSCode installed from Micro$oft website deb file (not using the shitty Canonical snap system).
Which package is the issue about?
Svelte for VS Code
Additional Information, eg. Screenshots
Its a bit random, I don’t manage to reproduce it 100% of time, I didn’t figure out the exact perfect conditions to reproduce it.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Feat req: "Organize All Imports Within Folder" · Issue #74855
Organize Imports is really nice, but would be better as a lint tool (kinda annoying when it trashes useful imports while I'm tinkering ......
Read more >Resolve and organize imports for all files in given folder
In visual studio 2017, I use intellisense to add import (manually for every missing references) and I use Ctrl+K,D to organize the imports....
Read more >Auto import | IntelliJ IDEA Documentation - JetBrains
The Optimize Imports feature helps you remove unused imports and organize import statements in the current file or in all files in a...
Read more >prettier-plugin-organize-imports - npm
A plugin that makes Prettier organize your imports (i. e. sorts, combines and removes unused ones) using the organizeImports feature of the ...
Read more >Organize files during import into Final Cut Pro - Apple Support
Note: The name of this option changes to “Copy to library storage location: location name” when the current library is set to an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Due to the “broken” status, the logical behaviour would be to do nothing.
I am experiencing the same issue also. It is hard to replicate consistently.
The most common time it happens is when there is a syntax error on the page like a missing end tag or a missing component import. If you hit save then all local component imports are removed.
Imports for stores etc are kept but not component imports.