jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle
Apache License 2.0
597 stars 50 forks source link

Remove trailing comma #318

Closed hantsy closed 1 year ago

hantsy commented 1 year ago

Upgraded to the latest version 3.14.0, when formatting the codes, it adds the trailing comma back by default.

I have tried to add the following .editorconfig according to the Ktlint docs, it does not work(all data classes, fun parameters still add commas).

[*.{kt,kts}]
ktlint_code_style=official
ij_kotlin_allow_trailing_comma_on_call_site=false
ktlint_standard_trailing-comma-on-call-site=false
ij_kotlin_allow_trailing_comma=false
ktlint_standard_trailing-comma-on-declaration-site=false
jeremymailen commented 1 year ago

This got me too the first time, but see here. The value to use is disabled rather that false.

hantsy commented 1 year ago

@jeremymailen Which one use disabled, the example config in the doc https://pinterest.github.io/ktlint/rules/configuration-ktlint/#trailing-comma-on-call-site uses a false there.

hantsy commented 1 year ago

Thanks @jeremymailen

[*.{kt,kts}]
ktlint_code_style=official
ij_kotlin_allow_trailing_comma_on_call_site=false
ktlint_standard_trailing-comma-on-call-site=disabled
ij_kotlin_allow_trailing_comma=false
ktlint_standard_trailing-comma-on-declaration-site=disabled

It works.

Another format I can not find in Ktlint config. I want to keep the ; in the enum class, I've created a new issue to describe it, https://github.com/jeremymailen/kotlinter-gradle/issues/319