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

Typescript import type statements are not sorted the same way in v4.0.0 and v4.1.0 #211

Closed
1 task done
acelaya opened this issue Feb 24, 2023 · 4 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@acelaya
Copy link

acelaya commented Feb 24, 2023

Your Environment

  • Prettier version: 2.8.4
  • node version [18.4.2]:
  • package manager: [yarn@1]
  • IDE: [VScode, Webstorm, CLI]

Describe the bug

We have just updated to v4.1.0 of this library, and now it tries to sort all import type statements together at the top of the imports block.

Based on the diff between v4.0 and v4.1, this seems like an intended behavior, and there's even mentions to new <THIRD_PARTY_TS_TYPES> and <TS_TYPES> tokens for importOrder option.

However, this is a breaking change, so I would expect it to be an opt-in behavior, or at least to provide an option to keep the previous behavior.

Would you consider providing such option to retain previous behavior?

To Reproduce

This script can be used to experiment the behavior:

import type { Component } from '@bar/bar';
import classnames from 'classnames';

import type { Foo } from '../aaa';
import Menu from './Menu';
import MenuItem from './MenuItem';

Running prettier --write on the file above using the configuration provided below, results in no changes when using v4.0.0

Using v4.1.0, it results in this:

import type { FilterOption } from '../aaa';
import type { Component } from '@bar/bar';
import classnames from 'classnames';

import Menu from './Menu';
import MenuItem from './MenuItem';

Expected behavior

The plugin keeps the same behavior, and it's safe to update from v4.0.0 to v4.1.0. Behavior changes and new features are observed only when opting-in to new features.

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

Our prettier config:

{
  "arrowParens": "avoid",
  "singleQuote": true,
  "importOrder": ["^[./]"],
  "importOrderSeparation": true
}

Contribute to @trivago/prettier-plugin-sort-imports

  • I'm willing to fix this bug 🥇
@acelaya acelaya changed the title Typescript import type statements are not sorted the same way between v4.0.0 and v4.1.0 Typescript import type statements are not sorted the same way in v4.0.0 and v4.1.0 Feb 24, 2023
@ayusharma ayusharma added bug Something isn't working and removed investigation labels Feb 24, 2023
@ayusharma
Copy link
Collaborator

Hi @acelaya, we mistakenly release a new breaking change feature (#153) in v4.1.0. I will release a fix now.

@acelaya
Copy link
Author

acelaya commented Feb 24, 2023

I see! Thanks for the quick response 🙂

@ayusharma
Copy link
Collaborator

ayusharma commented Feb 24, 2023

Fixed released in v4.1.1, @acelaya Could you please verify the fix ?

@acelaya
Copy link
Author

acelaya commented Feb 24, 2023

I was just testing it. Everything back to how it was before. Thanks for the super quick fix 🙂

@acelaya acelaya closed this as completed Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants