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
Addded TrailingCommaRule #886
Conversation
Current coverage is 86.11% (diff: 89.79%)@@ master #886 diff @@
==========================================
Files 112 114 +2
Lines 4959 5055 +96
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 4266 4353 +87
- Misses 693 702 +9
Partials 0 0
|
I think this rule can be on-by-default as long as it's also configurable. |
But how would I handle the configurations in the examples? They're very different according to the specified configuration. |
True, but that wouldn't be unprecedented. We have other rules where we reuse the convenient Could do the same here, although there's an argument to be made that we should have a nicer way to specify different test examples for each configuration to test. |
@jpsim Another (small) problem with the current description behavior is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I've given you write access, since you've done nothing but great contributions! So merge this whenever you feel it's ready.
|
||
* Add `TrailingCommaRule` to enforce/forbid trailing commas in arrays and | ||
dictionaries. The default is to forbid them, but this can be changed with | ||
the `mandatory_comma` configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just two trailing spaces: https://github.com/realm/SwiftLint/blob/master/CONTRIBUTING.md#tracking-changes
dictionaries. The default is to forbid them, but this can be changed with | ||
the `mandatory_comma` configuration. | ||
[Marcelo Fabri](https://github.com/marcelofabri) | ||
[#886](https://github.com/realm/SwiftLint/issues/886) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link to the issue this resolves, not the PR adding it: https://github.com/realm/SwiftLint/blob/master/CONTRIBUTING.md#tracking-changes
Fixes #883.
How would be the best way to handle both styles (mandatory comma and forbidden comma)? A configuration (if so, how should the rule description be)? Another rule?
I made this rule opt-in as even SwiftLint codebase isn't consistent. Thoughts?
PS: The changelog entry is missing on purpose as I thought it'd be better to think on how to handle both styles first.