I wish the trailing-comma rule defaulted to adding...
# ktlint
e
I wish the trailing-comma rule defaulted to adding a redundant trailing comma. It makes it easier to add items later on, and such changes only shows a diff on the actual changed line. Basically just benefits of having the comma there. šŸ™‚
s
It does do that for us with this .editorconfig. We just merged a PR with this exact change here. You can see where I edit the .editorconfig in the first commit then just let ktlint format and it adds redundant trailing commas everywhere.
e
Yeah, I get that you can configure it but I wish the default was the other way šŸ™‚ One thing I like a lot with Ktlint so far is that I never felt the need to configure it
But thx for the link, it'll save me some time ā¤ļø
šŸ¤— 1
s
Ah the default, now I understood what you were looking for. I personally would like it to be that way too, but apparently I’ve figured out that there’s plenty of people who actually don’t like trailing commas that much šŸ˜… It was a surprise to me for sure.
p
Rationale behind this is that the trailing comma is a feature which was added in a later kotlin version. Defaulting it to true would force all existing code bases to accept that as well. Also it might force code bases to be upgraded to kotlin versions that would accept trailing comma. That should be considered a breaking change which we try to avoid.
s
Right, and having a different set of ā€œdefaultsā€ for different Kotlin versions isn’t something that would be very fun either I suppose. Considering the case where someone upgrades their Kotlin version and then suddenly ktlint is screaming all over the code base about something they didn’t expect.
e
I see.. that's a strong argument šŸ™‚ Would be nice of Jetbrains to release some usage statistics so one can reason a bit more about such things (e.g. if <1% of users are still on Kotlin 1.3 then perhaps they can live with a stale version of Ktlint as well, but if they're 50% then it wouldn't make sense)
s
Maybe it’d be worth it to provide a link to this discussion in there to bring in a use case of how this data would be useful. Always easier to reason about and discuss among themselves regarding such a decision.
šŸ‘ 1
1112 Views