Yes correct. Since `1.0.0` the rule `blank-line-be...
# ktlint
p
Yes correct. Since
1.0.0
the rule
blank-line-before-declaration
is no longer experimental and runs always in code style
ktlint-official
.
j
Old message here Paul, wouldn't it be nice with a new line between class row definition and next line?
Copy code
class FooBar {
    val foo2 = "foo2"
To
Copy code
class FooBar {

    val foo2 = "foo2"
Disabling this rule would allow
Copy code
val foo3 = "foo3"
    fun bar1() {
And that I do want to prevent
p
HI Johan, I forgot to respond on this. It is an explicit choice to disallow the blank line before the first declaration in a class. In some cases it would help readability, in other case it would not help, or lead to inconsistencies. For example, why would a blank line before the declaration of
foo2
make sense, while no blank line is allowed before the closing brace of the class.
Copy code
class FooBar {

    val foo2 = "foo2"
}
Also see https://pinterest.github.io/ktlint/latest/faq/#can-a-new-toggle-be-added-to-optionally-enabledisable-format-code-in-a-particular-way
j
Thanks for following up! I would say the ending line just has a closing brace, which does not include any other characters. And the indent is at another level which makes a lot of difference. The goal is to prevent characters/text not being "directly connected" to each other to have space. At the same time one could argue that there should be an empty line before the closing brace.
p
I understand your arguments. It is impossible to let ktlint produce every format that any developer wants, and keeping it maintainable at the same time. I don't think this is important enough to add a new option, let alone to change the default behavior.
j
Should be default, no opt in 😉 At the same time I would argue that there shouldn't be a new line after function declaration which is almost the same thing but still not 😆
Thanks anyway for the input!