KtLint: Function name should start with a lowercase letter for Composable Functions
Asked Answered
T

1

5

Function name should start with a lowercase letter (except factory methods) and use camel case (cannot be auto-corrected)

I am trying to disable this warning but the rule I'm trying is not working. Below is the code that I'm using.

id("org.jlleitschuh.gradle.ktlint") version "12.0.3"

ktlint {
    version.set("1.1.0")
    debug.set(true)
    enableExperimentalRules.set(true)
    additionalEditorconfig.set(
        mapOf(
            "max_line_length" to "off",
            "ktlint_function_naming_ignore_when_annotated_with" to "Composable"
        ),
    )
}

Here is the link to the issue and library. JLLeitschuh/ktlint-gradle/issues/736

Tolu answered 1/1 at 11:50 Comment(1)
try this > rulset ruleset("standard") { rule("function-name") { // This rule disables the warning for function names starting with a lowercase letter description = "Function names should start with a lowercase letter." configuration = ".*" }Factotum
C
7

You can use the same rule from the .editorconfig file that you would add in the root of you project. So just add a line:

ktlint_function_naming_ignore_when_annotated_with = Composable
Celaeno answered 2/1 at 22:59 Comment(4)
Nope. Says property is not supported.Stoeber
@Stoeber Says so but it is still workingAshbaugh
It was added here: github.com/pinterest/ktlint/issues/2259#issuecomment-1732333419Catatonia
Configuration file should be named .editorconfig, not .ediConfig. See: pinterest.github.io/ktlint/0.49.1/rules/configuration-ktlintAnticosti

© 2022 - 2024 — McMap. All rights reserved.