mihon/buildSrc/src/main/kotlin/mihon.code.lint.gradle.kts
AntsyLich 32d2c2ac1b
Refrain from running spotless on weblate files
Those are akin to generated files and are likely to not follow our formatting
2024-10-13 23:02:35 +06:00

43 lines
1.2 KiB
Plaintext

import org.gradle.accessors.dm.LibrariesForLibs
plugins {
id("com.diffplug.spotless")
}
val libs = the<LibrariesForLibs>()
val xmlFormatExclude = buildList(2) {
add("**/build/**/*.xml")
projectDir
.resolve("src/commonMain/moko-resources")
.takeIf { it.isDirectory }
?.let(::fileTree)
?.matching { exclude("/base/**") }
?.let(::add)
}
.toTypedArray()
spotless {
kotlin {
target("**/*.kt", "**/*.kts")
targetExclude("**/build/**/*.kt")
ktlint(libs.ktlint.core.get().version)
.editorConfigOverride(mapOf(
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
"ktlint_standard_class-signature" to "disabled",
"ktlint_standard_discouraged-comment-location" to "disabled",
"ktlint_standard_function-expression-body" to "disabled",
"ktlint_standard_function-signature" to "disabled",
))
trimTrailingWhitespace()
endWithNewline()
}
format("xml") {
target("**/*.xml")
targetExclude(*xmlFormatExclude)
trimTrailingWhitespace()
endWithNewline()
}
}