Closed mattyg12three closed 10 months ago
I was having this same problem, the solution in my project was in the root gradle.kts file:
ktlint {
android.set(true)
outputToConsole.set(true)
enableExperimentalRules.set(true)
// This right here
additionalEditorconfig.set(
mapOf(
"function-naming" to "false"
)
)
}
I also had an IDE plugin installed alongside this, which I uninstalled.
I was having this same problem, the solution in my project was in the root gradle.kts file:
ktlint { android.set(true) outputToConsole.set(true) enableExperimentalRules.set(true) // This right here additionalEditorconfig.set( mapOf( "function-naming" to "false" ) ) }
I also had an IDE plugin installed alongside this, which I uninstalled.
This didn't work in my case, it throws an error so by the moment I'll stick with @Suppress("FunctionName")
, thanks anyways ❤️
Also it seems like is something more general:
https://github.com/pinterest/ktlint/issues/2259 https://youtrack.jetbrains.com/issue/KT-62260/Add-Composable-function-naming-rules-as-an-exception-to-the-coding-conventions
Hi again, finally I found a way to make it work!
In the .editorconfig
file at the root of the project you just need to put:
[*.{kt,kts}]
ktlint_code_style = android_studio
ktlint_function_naming_ignore_when_annotated_with=Composable
Thanks @AbrahamCardenesAcid for figuring this out!
additionalEditorconfigFile.set(file("/some/additional/.editorconfig")) // not supported with ktlint 0.47+
In documentation, it's mentioned that .editorconfig
will not be supported with 0.47+
. Will the above solution work for the latest version 1.1.1
?
.editorconfig is still supported, but you just have to rely on ktlint's built-in editorconfig file detection. We lost the ability to pass in a file path to ktlint
I did find one workaround that is to put
@Suppress("FunctionName")
in every place that is a composable function but is not the best approach to fix this 😢Originally posted by @AbrahamCardenesAcid in https://github.com/JLLeitschuh/ktlint-gradle/issues/736#issuecomment-1883280558