Open Stasky745 opened 3 months ago
@adrienverge would you be open to a PR for this? I was thinking maybe a line_break
rule that you can pass the root
option, so you need to skip a line between root elements and level
to say up until what level you need to jump a line between elements.
Hello Victor, I like the idea and would be open to such a contribution.
Instead of a new rule, maybe it would make sense to reuse the empty-lines
rule?
Such a feature needs to be well designed and future-proof, so before developing any code (+ tests), we need a clear proposal of new options to be able to achieve complex configurations like:
# 2 empty lines required at top level
# 1 empty line required at levels 2, 3 and 4, for mappings only
# 1 empty line required at levels 2, for sequences only
a:
k1: v1
k2:
x: 1
s: 1
t:
no: line
breaks: here
but: it's OK
u: 3
y: 2
z: 3
k3: v2
b:
- item
- item
- items:
- subitem
- subitem
- subitem
c: 3
Ideally, we would also need a way to tell whether an empty line is required before first items in sequences and mappings, e.g. in the first comment's example:
# No empty line before first item:
rules:
key-duplicates: …
trailing-spaces: …
# versus:
rules:
key-duplicates: …
trailing-spaces: …
Also, should lines with comments be accounted for?
# comment
a: 1
b: 2
# vs.
# comment
a: 1
b: 2
So to make it that this is right:
and this is wrong:
I'd say when the following line has less identation than the previous one to force a blank space. Is this possible?