Skip to content

Commit 9cd7841

Browse files
authored
Merge pull request swiftlang#205 from dabelknap/fix-orderedimports
Exit early in OrderedImports if there are no imports
2 parents 93e4443 + 62b694e commit 9cd7841

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/SwiftFormatRules/OrderedImports.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public final class OrderedImports: SyntaxFormatRule {
3838
var fileComment = Trivia()
3939
var impComment = Trivia()
4040
var (allImports, allCode) = getAllImports(node.statements)
41+
42+
if allImports.count == 0 {
43+
return Array(node.statements)
44+
}
4145

4246
if let firstImport = allImports.first,
4347
let firstStatement = node.statements.first,

0 commit comments

Comments
 (0)