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

chore: add import sort order to eslint #234

Closed
wants to merge 4 commits into from
Closed

Conversation

DNR500
Copy link
Contributor

@DNR500 DNR500 commented Apr 11, 2024

Jira: LF-7839

First attempt was using the eslint-plugin-simple-import-sort package. It did autofix but main issues where..

  • alphabetically sorting - doesn't factor in capitalisation like how we wanted. It is built with the intention of case insensitive sorting and can't be configured to do otherwise.
  • Any import that doesn't output a variable as part of the import statement will be moved to the top, this isn't great as sometimes importing code like this can have side effects where import order matters

The end solution using a mix of sort-imports and eslint-plugin-import
This PR is using a mix of eslints built in sort-imports and the eslint-plugin-import that we already have in the codebase. sort-import handles the sorting of named imports and the plugin does the rest. Also import statements without variable assignment are ignored. It should autofix imports too.

@DNR500
Copy link
Contributor Author

DNR500 commented Apr 17, 2024

Closing this PR as have switched to looking at prettier as an option - see #238

@DNR500 DNR500 closed this Apr 17, 2024
@DNR500 DNR500 deleted the eslint-sort-import-order branch April 17, 2024 10:55
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.

1 participant