pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.07k stars 504 forks source link

import checks #2561

Closed Dambldore closed 4 months ago

Dambldore commented 4 months ago

Hi, I am interesting is there a way to fail lint on that code:

fun test() {
    println(java.time.Instant.now())
}

i want that linter forced me to use explicit import in imports section or using typealias

may be it is already implemented and i need some changes in my editorconfig file or something like that

paul-dingemans commented 4 months ago

There is no such rule.

Also it can not be implemented as straight forward as you might expect. For example in code below, it would lead to compilation errors as call Foo is provided in two different packages:

import foo.Bar
import bar.Bar

val fooBar = Bar()

You might want to configure Intellij IDEA to do this for you

Screenshot 2024-02-24 at 16 33 26