pinterest / ktlint

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

Empty line between properties with annotations #2567

Closed maksym-severyn closed 6 months ago

maksym-severyn commented 7 months ago

Expected Rule behavior

Is it possible to add rule provides empty line between properties with annotations?

Currently, I found the rule with similar behavior, but appeals to declarations (https://pinterest.github.io/ktlint/1.1.1/rules/standard/#blank-line-between-declarations-with-annotations).

My expectation is:

data class TestEntity(
    @Max(5L)
    var field1: String,

    @Max(6L)
    var field2: String,

    @Max(6L)
    var field3: String,

    @Max(6L)
    var field4: String,

    @Max(6L)
    var field5: String
)

Current behavior:

data class TestEntity(
    @Max(5L)
    var field1: String,
    @Max(6L)
    var field2: String,
    @Max(6L)
    var field3: String,
    @Max(6L)
    var field4: String,
    @Max(6L)
    var field5: String
)

Used .editorconfig

root = true

[*.{kt,kts}]
max_line_length = 250
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false

Additional information

ktlint version 1.1.1 ktlint-gradle 12.1.0 gradle 8.5

paul-dingemans commented 7 months ago

What would be the rationale behind this? As far as I know, the Kotlin Coding coventions and Android Kotlin style guide do not recommend this. Neither is it a commonly accepted practice.

You can always create a custom rule when it is important to you. But at this moment, I do not any reason to add this to Ktlint.