nbadal / ktlint-intellij-plugin

Ktlint plugin for IntelliJ IDEA + Android Studio
MIT License
166 stars 24 forks source link

Trailing comma behaviour different from gradle plugin #218

Closed tobiberger closed 1 year ago

tobiberger commented 2 years ago

Over time, our team developed certain standards about where we want to use trailing commas. We like to use them in many places like injected service constructors, list builders etc. (places where it is common to add lines later) but we don't use them in more static places like method calls that just get one parameter. Ktlint itself is fine with this and although our fuzzy rules can't be enforced, it at least leaves everything as we wrote it. However, since I updated the IntelliJ Plugin (to 0.10.0), I get my trailing commas marked as a format error with the message Unnecessary trailing comma before ")" (trailing-comma). Of course I could enable ij_kotlin_allow_trailing_comma and ij_kotlin_allow_trailing_comma_on_call_site in editorconfig, but then also sets the commas in places where I don't want them.

Expected Behaviour: unless explicitly specified, ignore trailing commas, just like the default Kotlin formatter

paul-dingemans commented 1 year ago

Sorry, but this is enforced by Ktlint. Ktlint only allows you to disable the entire rule. When the rule is enabled, you get the trailing comma's everywhere. It might be annoying and sometimes ugly, but it is very consistent and as of that the team does not have to evaluate/discuss about whether your standards are being followed.