Ignoring Compose function naming error in Spotless(ktlint)

595 views Asked by At

I just added Spotless to my project with this config:

build.gradle.kts(:app)

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.diffplug.spotless") version "6.23.3"
}
...
spotless {
    kotlin {
        target("**/*.kt", "**/*.kts")
        ktlint()
        targetExclude("${layout.buildDirectory}/**/*.kt", "bin/**/*.kt", "buildSrc/**/*.kt")
    }
}

however, after running ./gradlew spotlessApply in terminal it gonna throw this error:

Error on line: 20, column: 5
rule: standard:function-naming
Function name should start with a lowercase letter (except factory methods) and use camel case

But in Line 20 I have a composable fun which should not start with a lowercase letter:

@Composable
fun ExplorerScreen() {
 ...
}

how can I ignore this error?

1

There are 1 answers

1
Yoonseop Shin On BEST ANSWER

Add ktlint_function_naming_ignore_when_annotated_with=Composable to .editorconfig

Check out this PR from the nowinandroid repo