Ignoring Compose function naming error in Spotless(ktlint)
Asked Answered
S

1

6

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?

Salas answered 15/12, 2023 at 14:43 Comment(0)
C
3

Add ktlint_function_naming_ignore_when_annotated_with=Composable to .editorconfig

Check out this PR from the nowinandroid repo

Christianly answered 29/12, 2023 at 8:29 Comment(1)
Feature was added to ktlint here: github.com/pinterest/ktlint/issues/2259#issuecomment-1732333419Cursed

© 2022 - 2024 — McMap. All rights reserved.