https://kotlinlang.org logo
#ktlint
Title
# ktlint
x

xenomachina

12/13/2023, 9:02 PM
Thanks. Ok, I now have
ktlint_standard_no-blank-line-in-list = disabled
in
.editorconfig
, but ktlint is still complaining "Unexpected blank line(s) in value argument list".
Copy code
$ cat .editorconfig 
ktlint_standard_no-blank-line-in-list = disabled

$ cat Foo.kt
val myMap =
    mapOf(
        // a comment about "foo"
        "foo" to computeFoo(),

        // a comment about "bar" and "baz"
        "bar" to computeBar(),
        "baz" to computeBaz(),
    )

$ ktlint Foo.kt 
/tmp/foo/Foo.kt:5:1: Unexpected blank line(s) in value argument list (standard:no-blank-line-in-list)
13:03:54.444 [main] WARN com.pinterest.ktlint.cli.internal.KtlintCommandLine - Lint has found errors than can be autocorrected using 'ktlint --format'

Summary error count (descending) by rule:
  standard:no-blank-line-in-list: 1
Copy code
$ ktlint -V
1.0.1
p

Paul Dingemans

12/14/2023, 5:51 PM
Your
.editorconfig
is not valid. Try:
Copy code
root = true

[*.{kt,kts}]
ktlint_standard_no-blank-line-in-list = disabled
x

xenomachina

12/15/2023, 3:49 AM
Thank you!
b

Benoît Liessens

12/17/2023, 10:32 AM
What’s the purpose of
root = true
?
p

Paul Dingemans

12/17/2023, 11:06 AM
It will stop traversal to the parent directory when trying to locate the
.editorconfig
file. Without this flag, ktlint might pick-up an
.editorconfig
which is located in a parent directory outside your project. Also, with deep hierarchies it does not need to search all parent up to the root.
👍 1
3 Views