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

Backticks in imports should be ignored for ordering purposes #1106

Closed
bethcutler opened this issue Mar 11, 2021 · 6 comments
Closed

Backticks in imports should be ignored for ordering purposes #1106

bethcutler opened this issue Mar 11, 2021 · 6 comments

Comments

@bethcutler
Copy link
Contributor

Expected Behavior

Imports are ordered alphabetically regardless of quotes

import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`

Observed Behavior

Imports with backticks are sorted above any other imports at the same level

import org.mockito.Mockito.`when`
import org.mockito.Mockito.verify

Steps to Reproduce

(See code samples above)

Your Environment

  • Version of ktlint used: 0.40.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): command line
@paulferaud
Copy link

Probably rarer, but it would also be possible for the escapes to appear as part of the package to.

import org.library.`typealias`.someImport

shashachu added a commit to shashachu/ktlint that referenced this issue Jun 29, 2021
shashachu added a commit to shashachu/ktlint that referenced this issue Jun 29, 2021
romtsn pushed a commit to paul-dingemans/ktlint that referenced this issue Aug 8, 2021
@ganadist
Copy link
Contributor

Kotlin Plugin for IntelliJ still provides old imports ordering behavior.
https://youtrack.jetbrains.com/issue/KTIJ-20283

@nbadal
Copy link
Contributor

nbadal commented Dec 20, 2021

I have submitted a change to the JetBrains Kotlin plugin to match this ordering, and it will eventually be released in an update 😁

@rocketraman
Copy link

I have submitted a change to the JetBrains Kotlin plugin to match this ordering, and it will eventually be released in an update grin

For reference:

https://youtrack.jetbrains.com/issue/KTIJ-19394
JetBrains/intellij-community#1879

According to YouTrack, should be part of 2022.1.

@hrach
Copy link

hrach commented Mar 8, 2022

Do I understand correctly that you have created inconsistency between IntelliJ platform and ktlint that will last at least a year before Android Studio gets stable on 2022.1 platform? And without any possibility to configure this?

Is there a chance that some AS will get it sooner? Alternatively, would you be open to accept PR allowing to revert this with some configuration?

@bogdanzurac
Copy link

Can confirm that we've hit this issue as well on Android as @hrach pointed out.

It's indeed a bit weird that this change was initially done in June 2021, with support inside IDEA not even out yet (coming in roughly a full year after the initial change in KtLint) and with AS getting the update based off of the new IDEA version probably after 1 more year, in 2023. So almost 2 years difference in time between the 2 dependencies (KtLint and actual IDE)...

Are there any contingencies in place for de-syncing issues like this? Can this be mitigated somehow for both the current situation as well as any possible future cases?

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

No branches or pull requests

8 participants