我想尝试一下Kotlin和ktlint,我很高兴看到它通过editorconfig文件支持制表符缩进(自从这个PR)。遗憾的是,这似乎对我不起作用。我以前没有使用过editorconfig,我可能犯了一些简单的错误。
我的.editorconfig
在根文件夹:
indent_style = tab
我的gradle文件:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val koinVersion: String by project
val junitVersion: String by project
plugins {
application
kotlin("jvm") version "1.4.30"
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}
group = "me.me"
version = "1.0-SNAPSHOT"
application {
mainClassName = "de.me.bot.translate.MainKt"
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation("com.sksamuel.hoplite:hoplite-core:+")
implementation("org.koin:koin-core:$koinVersion")
testImplementation("org.koin:koin-test:$koinVersion")
testImplementation(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "13"
}
但是运行gradle ktlintCheck仍然会抛出异常,因为意外的制表符。我不明白为什么。我用——debug命令运行它,但是它没有给我任何有用的信息。
这是我的项目:github.com
EditorConfig specification states:
所以你的。editorconfig文件应该是:除了根密钥之外,所有的密钥对必须位于一个section下面才能生效。
root = true
[*.{kt,kts}]
indent_style = tab