Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistentSwitchCaseSpacing can't match SwiftLint #1726

Open
jshier opened this issue Jun 11, 2024 · 0 comments
Open

consistentSwitchCaseSpacing can't match SwiftLint #1726

jshier opened this issue Jun 11, 2024 · 0 comments

Comments

@jshier
Copy link

jshier commented Jun 11, 2024

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.

  1. Single line cases don't have the rule enforced, so case value: "returnValue" doesn't need spacing.
  2. Extraneous spacing around single line cases is ignored, similar to the various "keep" settings for other rules.
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants