question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When use "organize imports", same folder imports are deleted

See original GitHub issue

Describe 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

  1. Create 3-4 components with simple slots, in the same $lib sub-folder.
  2. Create index files (JS and TS) to export them from that folder.
  3. In one of these components, create a hierarchy (one component inside another, for the slot), by using language tool imports on auto-completion.
  4. Auto-completion should have created one import line for each component.
  5. Trigger Organize Imports
  6. 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, using Svelte 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:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Maze-frcommented, May 18, 2022

Due to the “broken” status, the logical behaviour would be to do nothing.

1reaction
NoelOConnellcommented, May 13, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found