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

Exclude trailing_comma validation on single-line declarations #910

Closed
ZevEisenberg opened this issue Nov 30, 2016 · 5 comments
Closed

Exclude trailing_comma validation on single-line declarations #910

ZevEisenberg opened this issue Nov 30, 2016 · 5 comments

Comments

@ZevEisenberg
Copy link
Contributor

The typical arguments for requiring a trailing comma in arrays and dictionaries is so that adding or removing elements doesn't dirty adjacent lines in source control. However, that argument doesn't hold for single-line declarations such as this one I just came across in a project:

static let componentsToZeroForDay: [Calendar.Component] = [.hour, .minute, .second, .nanosecond]

It would be nice for SwiftLint to ignore cases like this. There could potentially be a separate rule that all arrays and dictionaries must be multiline, but I personally would leave that one off.

@ZevEisenberg
Copy link
Contributor Author

The existing warning is also annoying in cases of single-element arrays, like this:

let components = calendar.dateComponents([Calendar.Component.day], from: from, to: to)

By the way, my SwiftLint configuration includes:

trailing_comma:
  mandatory_comma: true

@jpsim
Copy link
Collaborator

jpsim commented Nov 30, 2016

Should be pretty easy to only report errors in single-line multi-line arrays and dictionaries.

@ZevEisenberg
Copy link
Contributor Author

Single-line? Don't you mean multi-line?

@jpsim
Copy link
Collaborator

jpsim commented Dec 1, 2016

Yes, sorry, updated.

@jpsim jpsim closed this as completed in #912 Dec 1, 2016
@jpsim
Copy link
Collaborator

jpsim commented Dec 1, 2016

Fixed by @marcelofabri in #912.

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