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

style: sort imports with prettier #1447

Merged
merged 5 commits into from
Jul 2, 2024
Merged

Conversation

larsrickert
Copy link
Collaborator

@larsrickert larsrickert commented Jun 28, 2024

closes #519

  • Add prettier plugin to sort imports (in the same way VSCode does it).

@larsrickert larsrickert requested a review from a team as a code owner June 28, 2024 09:27
Copy link

changeset-bot bot commented Jun 28, 2024

⚠️ No Changeset found

Latest commit: ef5fc91

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@larsrickert larsrickert enabled auto-merge (squash) June 28, 2024 09:28
@JoCa96 JoCa96 self-assigned this Jun 28, 2024
Copy link
Collaborator

@JoCa96 JoCa96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benefit over using the default eslint rule https://eslint.org/docs/latest/rules/sort-imports ?
The eslint rule also seems to work with .vue files

@JoCa96 JoCa96 disabled auto-merge June 28, 2024 09:55
@larsrickert
Copy link
Collaborator Author

Is there a benefit over using the default eslint rule https://eslint.org/docs/latest/rules/sort-imports ? The eslint rule also seems to work with .vue files

Yes because eslint use custom rules to sort the imports and you can not configure it to sort exactly like VSCode / Typescript language server which causes conflicts if you have enabled VS Code to also sort imports.

prettier-plugin-organize-imports uses theorganizeImports feature of the TypeScript language service API which is 1:1 what VS Code uses under the hood

@larsrickert larsrickert requested a review from JoCa96 June 28, 2024 13:51
@JoCa96
Copy link
Collaborator

JoCa96 commented Jul 2, 2024

the referenced issue has been closed, we can update the dependency:

closes #519

* Add prettier plugin to sort imports (in the same way VSCode does it).

* currently this does not work with `.vue` files because we would need to install a deprecated dependency which I don't want to install :) Once this is fixed in [Volar packages renamed simonhaenisch/prettier-plugin-organize-imports#98](https://github.com/simonhaenisch/prettier-plugin-organize-imports/issues/98), we should be able to just update the `prettier-plugin-organize-imports` dependency without any change on our side

@larsrickert larsrickert enabled auto-merge (squash) July 2, 2024 13:38
@larsrickert larsrickert merged commit 6c2c6fa into main Jul 2, 2024
19 checks passed
@larsrickert larsrickert deleted the style/prettier-sort-imports branch July 2, 2024 14:05
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

Successfully merging this pull request may close these issues.

Add prettier config to sort imports
3 participants