Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ktlint to 1.0.1 to enable support for composable functions #348

Closed
wants to merge 2 commits into from

Conversation

florianflmeyer
Copy link

Starting with ktlint version 1.0.1 it supports Composable functions by using the flag ktlint_function_naming_ignore_when_annotated_with=Composable. This tremendously helps modern Android projects to avoid custom rules for the naming guidelines for Composable functions.

@StylianosGakis
Copy link

I thought I'd be able to work around this for now by adding this to my settings.gradle.kts

buildscript {
  configurations.classpath {
    resolutionStrategy {
      force(
        "com.pinterest.ktlint:ktlint-rule-engine:1.0.1",
        "com.pinterest.ktlint:ktlint-rule-engine-core:1.0.1",
        "com.pinterest.ktlint:ktlint-cli-reporter-core:1.0.1",
        "com.pinterest.ktlint:ktlint-cli-reporter-checkstyle:1.0.1",
        "com.pinterest.ktlint:ktlint-cli-reporter-json:1.0.1",
        "com.pinterest.ktlint:ktlint-cli-reporter-html:1.0.1",
        "com.pinterest.ktlint:ktlint-cli-reporter-plain:1.0.1",
        "com.pinterest.ktlint:ktlint-cli-reporter-sarif:1.0.1",
        "com.pinterest.ktlint:ktlint-ruleset-standard:1.0.1",
      )
    }
  }
}

And adding ktlint_function_naming_ignore_when_annotated_with=Composable in my .editorconfig but the error seems to keep appearing.
Is this workaround not possible atm, or am I doing something wrong?

@rmarquis
Copy link

It should work, I'm using it.

Ensure the gradle daemon is properly stopped with ./gradlew --stop, otherwise the .editorconfig changes might not be properly detected.

@StylianosGakis
Copy link

Yes, I did make it work after all, I put it in my "root" build.gradle.kts https://github.com/HedvigInsurance/android/blob/69aae1d7a00abb3076fb344c991b6833a3477e0e/build.gradle.kts#L17-L35 and it worked well.
Before I tried putting it in settings.gradle.kts or the build.gradle.kts file of the :app module which both were wrong. I had never done this before so I just didn't know 😊

@jeremymailen
Copy link
Owner

Thank you @florianflmeyer -- I ended up having to fuss a little bit more with it to do the upgrade here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants