Hey, I'm new to ktlint and i want to define some c...
# ktlint
u
Hey, I'm new to ktlint and i want to define some custom rules in my micronaut kotlin project for formatting. How can i achieve it? Any suggestion or guide would be helpful. Thanks.
p
u
thanks @Paul Dingemans I'm just concerned about ignoring standard function name and added this in my build.gradle
Copy code
ktlint {
    android = false
    outputToConsole = true
    disabledRules = [
        "final-newline",
        "standard:function-naming"
    ]
}
but it's still raising error -
Function name should start with a lowercase letter (except factory methods) and use camel case (cannot be auto-corrected)
p
It loos that you are using a wrapper/plugin around ktlint. Please consult their documentation how to disable rules of ktlint.
u
Yes @Paul Dingemans i'm using this plugin
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
adding this on the top of the file worked for me in ignoring that file
@file:Suppress("ktlint")
@Paul Dingemans WDYT is it a recommended approach or we should avoid it?
p
You should only use that if you want to apply that for a single file. But you do not want to add that to every file. Best way to disable is to use '.editorconfig'.
w
Yes, the disabled rules property of ktlint-gradle is deprecated and doesnt work with newer ktlint versions (since 0.48) use editorconfig instead