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

Proposal: Enable trailing commas in our styleguide #748

Closed
oscarnylander opened this issue Oct 8, 2021 · 4 comments
Closed

Proposal: Enable trailing commas in our styleguide #748

oscarnylander opened this issue Oct 8, 2021 · 4 comments

Comments

@oscarnylander
Copy link
Contributor

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

@StylianosGakis
Copy link
Member

I am personally all for this change. Loved trailing commas ever since the day they were introduced!

@hugokallstrom
Copy link
Contributor

Love it!

@oscarnylander
Copy link
Contributor Author

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.

@StylianosGakis
Copy link
Member

Addressed by #1058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants