Skip to content

Custom ruleset dependency documentation is out of date #3048

@DavidBrunow

Description

@DavidBrunow

I recently implemented a custom ruleset and it was more difficult to figure out what dependencies that I needed than I expected it to be.

The ruleset template is great for learning how to write and test rules, but I naïvely thought that I could use the dependencies defined there as well, which I cannot because they are all specific to the template being embedded in the project.

The documentation also links to a blog post on creating a ruleset, but that blog post is from 7 years ago and enough has changed that those instructions for setting up dependencies cannot be followed.

After much trial and error and interactions with an LLM, I was able to create a build.gradle.kts with these contents which allowed me to create and test a ruleset:

plugins {
  kotlin("jvm") version "2.1.21"
}

repositories {
  mavenCentral()
}

dependencies {
  implementation("com.pinterest.ktlint:ktlint-cli-ruleset-core:1.6.0")
  implementation("com.pinterest.ktlint:ktlint-rule-engine-core:1.6.0")
  implementation(kotlin("stdlib"))

  testImplementation("junit:junit:4.12")
  testImplementation("org.slf4j:slf4j-simple:2.0.17")
  testImplementation("com.pinterest.ktlint:ktlint-test:1.6.0")
  testImplementation("com.pinterest.ktlint:ktlint-rule-engine-core:1.6.0")
}

Does that implementation look like y'all would expect? If so, would y'all welcome a PR updating the docs with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions