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
Supporting flexible configurations of TrailingCommaRule
#1552
Comments
This is entirely true. KtLint aims to provide a consistent code format throughout the entire codebase. So the trailing comma is either forced to all locations at call site or is not allowed anywhere at call site. This is indeed more strict than the Kotlin Coding conventions but it does not violate it. Leaving it to the developer discretion could lead to "endless" discussions about whether the trailing comma at call site is preferable in one example but not at another place. |
Actually completely enforcing or completely prohibiting also lead to an extensive discussion among my colleagues - The previous agreement was always to follow the Kotlin coding conventions but having ktlint taking an opinion does retrigger these conversations. |
I do understand that such an opinion of KtLint can lead to a debate in some teams. In other teams it will just be accepted as is and not leading to any discussion. Personally, I care more about consistency than about what specific setting is used. What could be done is splitting the Trailing comma rule in two different rules. Both rules will work exactly the same as current rule but will only handle the declaration or the call site. In your situation, the rule for handling the call site declaration can then be disabled. Are you willing to implement this? |
Definitely. I am happy to implement this by splitting the |
Cool. I would advise to wait untill PR's below are merged to master to prevent merge conflicts: |
Thank you for the tip - The merge conflict seems to be minimal so I am happy to wait |
Expected Behavior
The coding convention section about trailing commas - https://kotlinlang.org/docs/coding-conventions.html#trailing-commas
Using trailing commas has several benefits:
Trailing commas are entirely optional – your code will still work without them. The Kotlin style guide encourages the use of trailing commas at the declaration site and leaves it at your discretion for the call site.
I was expecting that I could configure ktlint to conform to the kotlin coding convention
Current Behavior
It seems that the existing implementation, as mentioned in #1032, either enforces commas or prohits commas at the call site.
Additional information
The text was updated successfully, but these errors were encountered: