New shiny toy from facebook! kotlin formatter base...
# announcements
y
New shiny toy from facebook! kotlin formatter based on google java format. We're happy to take bug reports and pull requests! There are some things it does differently than ktlint and intellij, details in the link https://github.com/facebookincubator/ktfmt
s
nice work! FYI while this does take a generally different philosophy than
ktlint
, the experimental indentation rule from ktlint should output code closer to
ktfmt
. you can enable it by passing the
--experimental
flag (note this will enable all the experimental rules, which may or may not be desirable for your case.)
👍 1
m
Looks like you've intentionally created very poorly formatted code to make others look worse. I'd also ask why you're not using the Jetbrains published Kotlin language formatting conventions rather than creating new ones?
n
I also have the same question as @Mike asked, why different conventions ?
y
We're using the same formatting conventions (where it makes sense to) that the rest of our java codebase uses via the rules set in google-java-format (https://github.com/google/google-java-format). One thing we do a lot of is chaining method calls (which is done for fluent apis like builders, testing assertions, and litho) and we wanted a formatter that would format kotlin and java code similarly for easy grokking. As mentioned in the post we're aiming for consistency between the java and kotlin parts of our codebase so there's less friction as new engineers ramp up on kotlin.
m
Personally, I'm opposed to that approach as you're now training people with expectations that won't be met when they look at other Kotlin code bases. I doubt you'd do that if you introduced a non-JVM language. But I also believe in this type of thing being a team decision. Just adding my thoughts.