tseisel
08/05/2022, 8:07 PMprettier
, which IMHO formats code in a cleaner way than those 2 Kotlin tools. ktlint looks promising, but I don't like that it also lint-checks code ; I'd expect it to focus on formatting. Any Kotlin alternative?Tim Oltjenbruns
08/05/2022, 8:22 PMTim Oltjenbruns
08/05/2022, 8:23 PMTim Oltjenbruns
08/05/2022, 8:23 PMOliver.O
08/05/2022, 8:25 PMspotless {
// WORKAROUND respect .editorconfig – <https://github.com/diffplug/spotless/issues/142>
val ktlintEditorConfig: Map<String, Any> = File("$rootDir/.editorconfig").useLines { lines ->
val editorConfigSettingRegex = Regex("""^\s*(\w+)\s*=\s*([^#\s]*)""")
lines.mapNotNull { line ->
editorConfigSettingRegex.matchEntire(line)?.let { match ->
val (name, value) = match.destructured
name to (value.toIntOrNull() ?: value)
}
}.toMap()
}
kotlin {
target("src/**/*.kt")
ktlint().editorConfigOverride(ktlintEditorConfig)
}
kotlinGradle {
ktlint().editorConfigOverride(ktlintEditorConfig)
}
}
With ktfmt, I did not like fighting the existing coding standard and the IDE.Charles Flynn
08/06/2022, 10:53 AMOliver.O
08/06/2022, 11:28 AM