Ktlint fails with Wildcard import (cannot be auto-corrected)

Viewed 2232

When I run gradlew ktlintCheck it fails with a lot of

Wildcard import (cannot be auto-corrected)

errors.

2 Answers

Create a .editorconfig file on root level and add amongst others:

disabled_rules=no-wildcard-imports

Came across this ktlint-gradle issue where it discussed about support to be added to ktlint-gradle for --disabled_rules. It eventually got included and a new cleaner way of disabling no-wildcard import check is as following.

ktlint {
    enableExperimentalRules.set(true)
    disabledRules.set(setOf("experimental:package-name", "no-wildcard-imports"))
}

FYI: Following rationale made --disabled_rules support possible.

Related