4Catalyzer / import-sort-style-4catalyzer

Sort style
0 stars 0 forks source link

Make import type stable #3

Open yodaiken opened 7 years ago

yodaiken commented 7 years ago

Current behavior: Transforms:

import NodeType, { getNodeResource } from 'x';
import type { Args, Context, Obj } from 'x';

into:

import type { Args, Context, Obj } from 'x';
import NodeType, { getNodeResource } from 'x';

and:

import type { Args, Context, Obj } from 'x';
import NodeType, { getNodeResource } from 'x';

into:

import NodeType, { getNodeResource } from 'x';
import type { Args, Context, Obj } from 'x';

Expected behavior

Either always place import type after or before import of the module.

(Will work on PR when I have some time.)

jquense commented 7 years ago

I think we should sort type imports in their own group? Interesting tho that this happens, I don't think the underlying library accounts for this import style.

taion commented 7 years ago

I think we put import type statements directly after the matching normal import statement.

itajaja commented 7 years ago

that's also easier impl-wise, probably

jquense commented 7 years ago

what is the matching import? You only use import type usually if you aren't actually importing from the module right?

taion commented 7 years ago

Well, where the import would normally go.

Also, sometimes you do – if e.g. you only need something for typing, but not to actually use.

yodaiken commented 7 years ago

With flow, you have to use import type to import anything exported as export type -- regardless of normal imports and and exports.

taion commented 7 years ago

By definition those are only for typing :p

jquense commented 7 years ago

anyone want to PR something to import-sort? I think we we just want the parser package to expose the AST nodes as well as their other bits and we can do all the stuff we want on our end

jquense commented 6 years ago

fixed upstream, and if we want to add any special rules around type import sorting lets make a proposal in another issue yeah?

jquense commented 6 years ago

or maybe this was that issue :P

anyone with a special request here, i don't care how we sort them, the metadata is in the nodes to sort them, when need to adjust the style.

taion commented 6 years ago

I just checked. This appears to be stable now.