-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Sorted imports auto correction #1845
Conversation
db1fca5
to
6d59025
Compare
I know @sberrevoets cares about this, so maybe he'd like to help review? |
@sammy-SC I think your approach is the right one. There will likely be edge cases, but sorting imports inside an import group (where a group spans from the first line that starts with That would cover your case, but also something like this: import ABC
#if os(iOS)
import UIKit
#elseif os(macOS)
import AppKit
#endif In that case everything for Warning should probably work the same way. If we introduce this concept of "import groups", the warning triggers can use that as well as I think a comment in the middle of a list of imports should be acceptable. |
6d59025
to
3695abe
Compare
@sberrevoets I agree that warning should work the same way. I think it should be done in different pull request thought. I will be happy to change the current implementation, please let me know whether I should do it in this PR or a different one. cc @jpsim |
5853fed
to
3695abe
Compare
3695abe
to
90256f8
Compare
If you create an abstraction here that the warning implementation would benefit from, then I think it's OK to do here, but I'll let @jpsim make the final call on that. |
Codecov Report
@@ Coverage Diff @@
## master #1845 +/- ##
==========================================
+ Coverage 88.89% 88.94% +0.04%
==========================================
Files 236 236
Lines 11511 11560 +49
==========================================
+ Hits 10233 10282 +49
Misses 1278 1278
Continue to review full report at Codecov.
|
@sberrevoets @jpsim I took the liberty and changed it here. |
Closing in favor of #1922 |
Makes
sorted_imports
corractable.Feature request: #1822
I was not sure how to handle this case.
the code above will generate warning from
sorted_imports
but autocorrection won't fix it because I am not sure what to do with the comment. The code above will result into following correction. Same thing happens if there is a code in place of the comment.Any comments or suggestions are very welcome.