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

Automatically sort imports #248

Merged
merged 2 commits into from Nov 11, 2022
Merged

Automatically sort imports #248

merged 2 commits into from Nov 11, 2022

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Nov 11, 2022

I've added some configuration to the import/order rule, to make sure we automatically sort imports (fixable with eslint --fix). Imports will be sorted in two groups:

  1. Node.js builtins and external modules (i.e., imports from node_modules).
  2. Local (relative) imports.

Within these groups, imports are sorted alphabetically. A new line is placed between each import group, and the actual code.

{
// This means that there will always be a newline between the import
// groups as defined below.
'newlines-between': 'always',
Copy link
Member Author

Choose a reason for hiding this comment

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

I think personally this makes it easier to distinguish external imports from internal ones. I'm open to change this however.

@Mrtenz Mrtenz marked this pull request as ready for review November 11, 2022 09:57
@Mrtenz Mrtenz requested a review from a team as a code owner November 11, 2022 09:57
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

😄 🕺🏻

@Mrtenz Mrtenz merged commit 6a834ed into main Nov 11, 2022
@Mrtenz Mrtenz deleted the mrtenz/sort-imports branch November 11, 2022 14:27
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.

None yet

4 participants