I was eager to try the new consistentSwitchCaseSpacing rule. However, without any configuration it can't match the styling SwiftLint checks with its vertical_whitespace_between_cases rule. Namely, it has a few points.
Single line cases don't have the rule enforced, so case value: "returnValue" doesn't need spacing.
Extraneous spacing around single line cases is ignored, similar to the various "keep" settings for other rules.
Only when the case has more than one line is the spacing enforced, and we want it always enforced.
For instance, this is a common pattern:
switch value {
case .one: "one"
case .two: "two"
case .three: "three" // This is special.
default:
break
}
or even just
switch value {
case .one: "one"
case .two: "two"
case .three: "three"
default:
break
}
but this would have enforced spacing because the cases have a second line:
switch value {
case .one:
"one"
case .two:
"two"
case .three:
"three"
default:
break
}
So it would be nice if the rule could be configured to match the SwiftLint behavior, or otherwise have options.
I was eager to try the new
consistentSwitchCaseSpacing
rule. However, without any configuration it can't match the styling SwiftLint checks with itsvertical_whitespace_between_cases
rule. Namely, it has a few points.case value: "returnValue"
doesn't need spacing.For instance, this is a common pattern:
or even just
but this would have enforced spacing because the cases have a second line:
So it would be nice if the rule could be configured to match the SwiftLint behavior, or otherwise have options.