Proposal: Enable trailing commas in our styleguide
Closed this issue · 4 comments
I think we should enable trailing commas in our styleguide. My primary motivation is that it increases the readability of git diffs. See the following example:
val example = listOf(
1,
2
)
which when extended will produce the following diff:
val example = listOf(
1,
~ 2, // changed line
+ 3 // added line
)
vs
val example = listOf(
1,
2,
)
which produces the following diff:
val example = listOf(
1,
2,
+ 3, // only added line
)
We can enforce this change using ktlint
, when support for this flag is merged to the mainline branch (pinterest/ktlint#709)
What are your opinions on the subject? @StylianosGakis @hugokallstrom
I am personally all for this change. Loved trailing commas ever since the day they were introduced!
Love it!
Looks like trailing commas has been merged now.
However, the latest version of ktlint
has not been published to brew
. When that is done, let's get this rolling 🙂
While we're on it, I also propose that we switch from the 'regular' version of ktlint
to the --android
-version. Doing that (+ adding trailing commas) will be a fairly large PR, but it will be only cosmetic changes that hopefully can be auto-applied.
Addressed by #1058