Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: group type-imports when sorting Identifiers #25

Closed
3 tasks
fbartho opened this issue May 19, 2022 · 5 comments
Closed
3 tasks

Feature: group type-imports when sorting Identifiers #25

fbartho opened this issue May 19, 2022 · 5 comments

Comments

@fbartho
Copy link
Collaborator

fbartho commented May 19, 2022

Is your feature request related to a problem?
In #20 we're offering an option to migrate import type { expressions into value-imports when needed `import {type
In #22 we're discussing deleting that configuration-flag, and instead having an opinionated default.

We realized that we probably want to have some configuration for deciding which mode we want.

Example:

import type {A} from 'a';
import {B} from 'a';
import type {C} from 'a';
import {D} from 'a';

Desired Flavors:

  1. Feature: importOrderMergeDuplicateImports #19 (without Feature: importOrderCombineTypeAndValueImports #20) would produce
import type { A, C } from 'a';
import { B, D } from 'a';
  1. Feature: importOrderMergeDuplicateImports #19 with Feature: importOrderCombineTypeAndValueImports #20 would produce
import  { type A, B, type C, D } from 'a';
  1. Not available yet:
import  { type A, type C, B, D } from 'a';
  1. Not available yet: (witnessed in @IanVS's codemod)
import  { B, D, type A, type C } from 'a';

Describe the solution you'd like

  1. "don't merge any imports" should be spelled importOrderMergeTypeImports: "disable"
  2. in New major version -- what do we want to change #22 we offered that Desired Flavor 1 could be spelled as importOrderMergeTypeImports: "separate"
  3. in New major version -- what do we want to change #22 we offered that Desired Flavor 2 could be spelled as importOrderMergeTypeImports: "mixed"
  4. we could spell Desired Flavor 3 as importOrderMergeTypeImports: "mixed-first"
  5. we could spell Desired Flavor 4 as importOrderMergeTypeImports: "mixed-last"

Describe alternatives you've considered

  • Pick a specific default, and don't offer any options
  • For sub feature "mixed" maybe mixed should actually just refer to one of the options, and not offer the others.

Open concerns

  • Should this option be spelled importOrderMergeImports instead?
  • Should "separate" aggressively unmerge any type imports in a value expression into 2 import statements import type + import {} expressions?
  • What should the default be?
@fbartho
Copy link
Collaborator Author

fbartho commented May 19, 2022

I vote the default value should be "mixed-first" or "mixed-last" ahead of the other options.

@fbartho
Copy link
Collaborator Author

fbartho commented May 19, 2022

I forgot to propose the option of "group all the import type expressions at the top" -- it's not one I want, but I can update the discussion if we want that.

@IanVS
Copy link
Owner

IanVS commented Oct 27, 2022

How that it's possible to combine type and value imports (importOrderCombineTypeAndValueImports) and to place type imports where desired (#44), I think the only thing that's missing from this request is to control the order of mixed type and value imports. I made the call to always put types last as part of importordersortspecifiers, and I don't think it's important enough of a style difference to add an option just to control it, when we're trying to cut down on our current options.

So, with that said, I think that main request in this issue is done now, right? Can we close it, or is there still more to do?

@fbartho
Copy link
Collaborator Author

fbartho commented Oct 27, 2022

I think you've made the necessary decision, right?

@IanVS
Copy link
Owner

IanVS commented Oct 27, 2022

Let's run with this for now, and if we hear an outcry from users we can find a way to adjust in the future. Thanks!

@IanVS IanVS closed this as completed Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants