JLLeitschuh / ktlint-gradle

A ktlint gradle plugin
MIT License
1.47k stars 162 forks source link

Same Issue #742

Closed mattyg12three closed 10 months ago

mattyg12three commented 10 months ago
          Hi, I'm having the same problem. Is there any solutions or workaround? 

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

mattyg12three commented 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.

AbrahamCardenesAcid commented 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.

This didn't work in my case, it throws an error so by the moment I'll stick with @Suppress("FunctionName") , thanks anyways ❤️

image

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

AbrahamCardenesAcid commented 10 months ago

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
wakingrufus commented 10 months ago

Thanks @AbrahamCardenesAcid for figuring this out!

AbdullahJaved-dev commented 10 months ago

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?

wakingrufus commented 10 months ago

.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