-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
tslint: Enable trailing-comma #2407
Conversation
I like when people use a trailing comma in comma-separated definitions. Turns out there is a tslint rule for it! And it also has an autofixer, so I ran tslint --fix to generate this patch. I sampled a few files and the results seems good. For example, I would prefer this: const foo = [ A, B, C, ]; rather than: const foo = [ A, B, C ]; The main reason is that it simplifies diffs where you add a new item. You don't need to change the line containing "C". With the "multiline" setting, things like this are not affected: const foo = [ A, B, C ]; If you want to add "D", you'll need to change the line anyway, so the comma would not help here. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
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.
This is more consistent, looks like a quick change, and the tests still pass: LGTM.
How about asking the whole team first? changes in code styles should not be a preference of one person |
Right, this is the place to discuss it. |
I do not like it because it feels like you forgot something. But if the majority wants it, let's do it. |
I doubt that everybody is watching all PRs. Please discuss it on the dev meeting when everybody is back from vacations.
I agree with @kittaakos that it does not look nice and IMHO real value is minimal. |
One of the reason I like it is that it can help with merge conflicts. If two different commits add a last item then you don't need to fix the comma. |
I like when people use a trailing comma in comma-separated definitions.
Turns out there is a tslint rule for it! And it also has an autofixer,
so I ran tslint --fix to generate this patch. I sampled a few files and
the results seems good.
For example, I would prefer this:
rather than:
The main reason is that it simplifies diffs where you add a new item.
You don't need to change the line containing "C".
With the "multiline" setting, things like this are not affected:
If you want to add "D", you'll need to change the line anyway, so the
comma would not help here.
Signed-off-by: Simon Marchi simon.marchi@ericsson.com