language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Arranged imports from code actions misses space in-between

Open CrendKing opened this issue 3 years ago • 2 comments

Describe the bug

When I use the "Organize Imports" code action on a svelte file, the items in the braces is only delimited by ,, not , .

Reproduction

  1. import { a, b, d, c } from './Foobar.svelte'
  2. Right click -> Source Action -> Organize Imports
  3. It becomes import { a,b,c,d } from './Foobar.svelte'

Expected behaviour

import { a, b, c, d } from './Foobar.svelte'

System Info

  • OS: Windows 11
  • IDE: VSCode 1.17.0

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

CrendKing avatar Aug 08 '22 01:08 CrendKing

I guess it should somehow preserve formatting, rather than placing spaces. Otherwise after this issue being fixed some other guy would open issue about unwanted spaces after executing "Organize imports".

ZerdoX-x avatar Aug 09 '22 14:08 ZerdoX-x

I saw this repo (e.g.) uses space in its imports all the time, so I thought it's some kind of coding style convention in TypeScript. To me, it's much more difficult to distinguish each name without the space. But if that's not universally accepted standard, then I guess either won't fix this, or provide a config to satisfy everyone.

Google's TypeScript Style Guide has an example that uses comma space: https://google.github.io/styleguide/tsguide.html#optimization-compatibility-for-module-object-imports

import {method1, method2} from 'utils';
class A {
  readonly utils = {method1, method2};
}

CrendKing avatar Aug 09 '22 23:08 CrendKing