Larry Garfield
06/27/2024, 7:24 PMktlint_standard_trailing-comma-on-declaration-site
setting, the documentation is… highly confusing. https://pinterest.github.io/ktlint/latest/rules/standard/#trailing-comma-on-declaration-site
It’s not clear if enabled or disabled will say yes to trailing commas. But I tried both (in .editorconfig
), and in both cases, ktlint is removing trailing commas from my code base. I want it to either leave them alone or enforce having them, but neither enabled nor disabled is having that effect. What am I missing here?Daniel Pitts
06/27/2024, 8:43 PMDaniel Pitts
06/27/2024, 8:45 PMKtLint values consistent formatting more than a per-situation decision, and therefore uses this setting to enforce/disallow usage of trailing comma's in declarations.
Larry Garfield
06/27/2024, 10:41 PMDaniel Pitts
06/28/2024, 2:52 AMLarry Garfield
06/28/2024, 1:49 PMDaniel Pitts
06/28/2024, 2:40 PMLarry Garfield
06/28/2024, 3:17 PMDaniel Pitts
06/28/2024, 3:17 PMLarry Garfield
06/28/2024, 3:17 PMDaniel Pitts
06/28/2024, 3:18 PMLarry Garfield
06/28/2024, 3:18 PMDaniel Pitts
06/28/2024, 3:18 PMDaniel Pitts
06/28/2024, 3:19 PMLarry Garfield
06/28/2024, 3:24 PMroot = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_standard_trailing-comma-on-call-site = enabled
ktlint_standard_trailing-comma-on-declaration-site = enabled
Results in many diffs like this:
<http://logger.info|logger.info>(
String.format(
"FulfillmentEventsListener - onFulfillmentEvent : " +
"processingOrderId = %s, customerid = %s, eventType = %s, eventPhase = %s",
fulfillmentEvent.processingOrderId,
fulfillmentEvent.customerId,
fulfillmentEvent.eventType,
- fulfillmentEvent.eventPhase,
+ fulfillmentEvent.eventPhase
),
)
When I would expect it to result in the opposite: Adding commas in places where they’re not present.Daniel Pitts
06/28/2024, 4:18 PM[*.{kt,kts}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
Daniel Pitts
06/28/2024, 4:20 PMij_kotlin_allow_trailing_comma
, even though the suppress or disable rule
section lists the ktlint_standard_trailing-comma-on-declaration-site = enable
Larry Garfield
06/28/2024, 4:47 PMLarry Garfield
06/28/2024, 4:53 PMLarry Garfield
06/28/2024, 4:53 PMDaniel Pitts
06/28/2024, 4:53 PMLarry Garfield
06/28/2024, 4:54 PMDaniel Pitts
06/28/2024, 4:55 PMLarry Garfield
06/28/2024, 4:55 PMLarry Garfield
06/28/2024, 4:56 PMDaniel Pitts
06/28/2024, 4:57 PMLarry Garfield
06/28/2024, 4:57 PMDaniel Pitts
06/28/2024, 4:59 PMLarry Garfield
06/28/2024, 4:59 PMLarry Garfield
06/28/2024, 5:53 PM