prettier-plugin-sort-imports icon indicating copy to clipboard operation
prettier-plugin-sort-imports copied to clipboard

add option to put `import type` statements at the top

Open opensas opened this issue 2 years ago • 8 comments

I have the following imports:

import type { ComponentProps } from 'svelte';
import { writable } from 'svelte/store';

import type Modal from './Modal.svelte';

And I'd like some configuration to sort all the import type statements at the top, like this:

import type { ComponentProps } from 'svelte';
import type Modal from './Modal.svelte';

import { writable } from 'svelte/store';

opensas avatar Jan 04 '23 20:01 opensas

Would also be nice if we could configure type imports to be separated by group.

import type { foo } from 'some-lib'
import type { bar } from 'other-lib'

import type { baz } from '@/baz'

import qux from 'some-lib'

import quux from '@/quux'

nVitius avatar Jan 10 '23 03:01 nVitius

We had this in #153 and it will be released in the next major version. We released it in v4.1.0 mistakenly and reverted it later on.

If you still like to try then install v4.1.0 and use importOrder: ["<THIRD_PARTY_TS_TYPES>", "^[./]", "<TS_TYPES>^[./]"],

ayusharma avatar Feb 24 '23 20:02 ayusharma

Possible to re-include types for a 4.x version? I would like to update prettier to v3

Thanks :)

lanarchyste avatar Jul 24 '23 17:07 lanarchyste

Would this also work when using the import { type Something } ... syntax?

jahvi avatar Aug 30 '23 09:08 jahvi

I join in the wait. I would like to have the type sorting function available using prettier 3.

50l3r avatar Nov 03 '23 18:11 50l3r

Any news on this?

mrspartak avatar Nov 26 '23 17:11 mrspartak

Is this feature ever available on any public releases? I cannot wait to use this nice stuff.

LiuJi-Jim avatar Mar 21 '24 00:03 LiuJi-Jim

Any updates ?

mehdikhody avatar Apr 05 '24 23:04 mehdikhody