Make vertical_whitespace_between_cases rule work when case block ends with a string literal (#5628)

This commit is contained in:
Muhammet Ilendemli
2024-06-22 17:50:08 +00:00
committed by GitHub
parent 1f4b422adf
commit fa5f98f6f3
2 changed files with 22 additions and 1 deletions
+5
View File
@@ -31,6 +31,11 @@
`unneeded_synthesized_initializer` rule.
[SimplyDanny](https://github.com/SimplyDanny)
[#5153](https://github.com/realm/SwiftLint/issues/5153)
* Make `vertical_whitespace_between_cases` rule work for
cases ending with a string literal.
[ilendemli](https://github.com/ilendemli)
[#5612](https://github.com/realm/SwiftLint/issues/5612)
* Ignore access level modifiers restricted to value setting in
`extension_access_modifier` rule.
@@ -3,7 +3,7 @@ import SourceKittenFramework
private extension SwiftLintFile {
func violatingRanges(for pattern: String) -> [NSRange] {
return match(pattern: pattern, excludingSyntaxKinds: SyntaxKind.commentAndStringKinds)
return match(pattern: pattern, excludingSyntaxKinds: SyntaxKind.commentKinds)
}
}
@@ -57,6 +57,22 @@ struct VerticalWhitespaceBetweenCasesRule: Rule {
]
private static let violatingToValidExamples: [Example: Example] = [
Example("""
switch x {
case 0..<5:
return "x is valid"
↓ default:
return "x is invalid"
}
"""): Example("""
switch x {
case 0..<5:
return "x is valid"
default:
return "x is invalid"
}
"""),
Example("""
switch x {
case 0..<5: