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

fix: import order rules #20

Merged
merged 6 commits into from
Jul 23, 2024
Merged

fix: import order rules #20

merged 6 commits into from
Jul 23, 2024

Conversation

ChaituVR
Copy link
Member

@ChaituVR ChaituVR commented Jul 23, 2024

Summary:

Context: snapshot-labs/sx-monorepo#383 (comment)
Often we miss sorting imports, this should be automated with eslint rules

  • Add the sort-imports rule to sort imports inside one file/lib
  • Add the import/order rule to sort imports in groups in order: ['builtin', 'external', 'internal', 'type']

How to test:

  • Go to any project, for example, in mono repo, edit package.json,
  • Under eslintConfig add config from this PR (add double quotes)
  • Change the order of imports other than ['builtin', 'external', 'internal', 'type'], see the error

@ChaituVR ChaituVR marked this pull request as ready for review July 23, 2024 13:19
@ChaituVR ChaituVR requested review from wa0x6e and Sekhmet July 23, 2024 13:24
Copy link
Member

@Sekhmet Sekhmet left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Member

@Sekhmet Sekhmet left a comment

Choose a reason for hiding this comment

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

Would be great to have it integrated with prettier at some point as well as juggling imports manually will be annoying, thinking of alphabetic order in the head when organising your imports vs just having it work on save.

@wa0x6e
Copy link

wa0x6e commented Jul 23, 2024

Those rules will only raise warnings, and will not auto fix ?

Most of the import warnings I create are mostly because vscode auto-import the packages for me when I type a function, and it append them at the end. Would be good if we can just forgot about importing things

@ChaituVR
Copy link
Member Author

Those rules will only raise warnings, and will not auto fix ?

Most of the import warnings I create are mostly because vscode auto-import the packages for me when I type a function, and it append them at the end. Would be good if we can just forgot about importing things

These should be auto fixed with --fix, to auto fix on save we should do It on the editor level (I will create a separate PR on monorepo)

@ChaituVR ChaituVR merged commit 5b398b4 into master Jul 23, 2024
1 check passed
@ChaituVR ChaituVR deleted the fix-import-order branch July 23, 2024 16:46
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.

3 participants