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

Allow enabling custom rulesets for ktlint #1220

Closed
jonesetc opened this issue May 25, 2022 · 3 comments · Fixed by #1896
Closed

Allow enabling custom rulesets for ktlint #1220

jonesetc opened this issue May 25, 2022 · 3 comments · Fixed by #1896

Comments

@jonesetc
Copy link

Follow up from #409 (comment)

I had been watching the issue around this before, but it was closed after just the first request (experimental ruleset) was completed. Currently my team runs a second formatting plugin (https://github.com/JLLeitschuh/ktlint-gradle) that reruns ktlint so that we can use a custom ruleset that helps us avoid some common pitfalls in our codebase.

The way that we use this today looks roughly like:

build.gradle.kts

plugins {
    java
    kotlin("jvm")
    id("com.diffplug.spotless")
    // The extra ktlint plugin
    id("org.jlleitschuh.gradle.ktlint")
}

dependencies {
    // Add the ruleset from a submodule
    ktlintRuleset(project(":linting"))
}

spotless {
    kotlin {
        target("**/*.kt")
        ktlint()
    }
}

// After running spotlessApply or spotlessCheck, run a last check with the custom rules
tasks.spotlessKotlin {
    finalizedBy(
        "ktlintCheck"
    )
}
@bengaudiosi-toast
Copy link

Any movement on this?

@Goooler
Copy link
Contributor

Goooler commented Nov 21, 2023

Addressing the fix to #1896.

@nedtwigg
Copy link
Member

Implemented in plugin-gradle 6.23.0 and plugin-maven 2.41.0 thanks to the incredibly prolific @Goooler.

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

Successfully merging a pull request may close this issue.

4 participants