Skip to content

Commit 7285091

Browse files
committed
Exclude extensions from trailing comma support in Swift 6.1
1 parent a583782 commit 7285091

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/Rules/TrailingCommas.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public extension FormatRule {
8888
let keywordIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, before: identifierIndex),
8989
let keyword = formatter.token(at: keywordIndex),
9090
keyword.isKeyword,
91-
["class", "actor", "struct", "enum", "protocol", "extension", "typealias", "func"].contains(keyword.string)
91+
["class", "actor", "struct", "enum", "protocol", "typealias", "func"].contains(keyword.string)
9292
{
9393
trailingCommaSupported = true
9494
}

Tests/Rules/TrailingCommasTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,15 @@ class TrailingCommasTests: XCTestCase {
10811081
T2,
10821082
Bool
10831083
>
1084+
1085+
extension Dictionary<
1086+
String,
1087+
Any
1088+
> {}
10841089
"""
10851090

10861091
let options = FormatOptions(trailingCommas: true, swiftVersion: "6.1")
1087-
testFormatting(for: input, rule: .trailingCommas, options: options)
1092+
testFormatting(for: input, rule: .trailingCommas, options: options, exclude: [.emptyExtensions, .typeSugar])
10881093
}
10891094

10901095
func testTrailingCommasRemovedFromGenericList() {

0 commit comments

Comments
 (0)