Fix rewriter of `trailing_semicolon` rule wrongly removing trailing comments (#4818)
This commit is contained in:
parent
fb89ab2fb5
commit
6983c813c8
|
@ -182,6 +182,11 @@
|
|||
[Martin Redington](https://github.com/mildm8nnered)
|
||||
[#4788](https://github.com/realm/SwiftLint/issues/4788)
|
||||
|
||||
* Fixed correction for `trailing_comma` rule wrongly removing trailing
|
||||
comments.
|
||||
[Martin Redington](https://github.com/mildm8nnered)
|
||||
[#4814](https://github.com/realm/SwiftLint/issues/4814)
|
||||
|
||||
## 0.50.3: Bundle of Towels
|
||||
|
||||
#### Breaking
|
||||
|
|
|
@ -21,7 +21,8 @@ struct TrailingSemicolonRule: SwiftSyntaxCorrectableRule, ConfigurationProviderR
|
|||
],
|
||||
corrections: [
|
||||
Example("let a = 0↓;\n"): Example("let a = 0\n"),
|
||||
Example("let a = 0↓;\nlet b = 1\n"): Example("let a = 0\nlet b = 1\n")
|
||||
Example("let a = 0↓;\nlet b = 1\n"): Example("let a = 0\nlet b = 1\n"),
|
||||
Example("let foo = 12↓; // comment\n"): Example("let foo = 12 // comment\n")
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -65,8 +66,7 @@ private extension TrailingSemicolonRule {
|
|||
}
|
||||
|
||||
correctionPositions.append(node.positionAfterSkippingLeadingTrivia)
|
||||
// Is there a better way to remove a node? Should we somehow keep trailing trivia?
|
||||
return super.visit(TokenSyntax(.semicolon, presence: .missing))
|
||||
return .unknown("").with(\.trailingTrivia, node.trailingTrivia ?? .zero)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue