Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Maintain consistent order of imports #189

Closed
gabrielittner opened this issue Apr 18, 2018 · 7 comments · Fixed by #366
Closed

Maintain consistent order of imports #189

gabrielittner opened this issue Apr 18, 2018 · 7 comments · Fixed by #366

Comments

@gabrielittner
Copy link
Contributor

Currently imports aren't sorted at all and single empty lines within the imports aren't removed.

See https://android.github.io/kotlin-guides/style.html#import-statements

@shyiko
Copy link
Collaborator

shyiko commented Apr 18, 2018

ktlint has ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/ImportOrderingRule.kt (test) but it's disabled as it's incompatible with the way AS orders imports (not with the actual Android Koltin Style Guide, though). At least that was the case when I wrote the rule.

@gabrielittner
Copy link
Contributor Author

Is there a way to manually enable the rule?

@shyiko
Copy link
Collaborator

shyiko commented Apr 19, 2018

Other than copy&pasting ImportOrderingRule to your own ruleset, not at the moment (unfortunately).

@gabrielittner
Copy link
Contributor Author

@shyiko Can you describe the incompatibility you mentioned?

@iikirilov
Copy link

This may be offtopic but I do not find a way to specify an import order :( - I can live without alphabetical order until there is some proposal how to fix it.

@shyiko shyiko changed the title Format imports Maintain consistent order of imports Feb 12, 2019
@Tapchicoma
Copy link
Collaborator

@shyiko would it make sense to include disabled ImportOrderingRule into --experimental flag rules? So those who need it can use it.

@shashachu
Copy link
Contributor

@Tapchicoma That seems totally reasonable.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants