Skip to content

sorted_imports in 0.62.0 doesn't correctly distinguish groups #6317

@jszumski

Description

@jszumski

Bug Description

The rewritten sorted_imports rule doesn't correctly distinguish import groups that also contain comments. Leading comments stay with the import node they're associated with, but I'd expect that to break on newlines.

Bad correction I get when I expected the original code not to trigger a violation:

+// comment for second group
+import AAA
 //
 // Copyright © Foo
 //
 
 import DDD
 import FFF
-
-// comment for second group
-import AAA
 import BBB
 import CCC

Related example where the correction is placed above the first item's trivia when I would expect it to split on the new line:

+import AAA
 //
 //  Copyright © Foo
 //
 
 import class BBB.View
-import AAA

Environment

  • SwiftLint 0.62.1
  • Xcode 26.0.1
  • installed from source

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions