sbaudoin / yamllint

YAML Linter written in Java
Apache License 2.0
20 stars 14 forks source link

Add min-spaces-after to hyphen rule #52

Closed mikebell90 closed 12 months ago

mikebell90 commented 1 year ago

Use case

foo:
     -broken

vs

foo:
    - correct
sbaudoin commented 12 months ago

Hello. Your example does not make much sense. As per the YAML 1.1 spec, "Block sequences indicate each entry with a dash and space". If you do not put a space then you have a scalar. I may implement such a rule but the supported min space value would be 1, not 0. Any thought?

mikebell90 commented 12 months ago

Exactly. It's not valid yaml. But users have entered it before and we'd like to catch it. Exactly how implementation wise is certainly your choice

sbaudoin commented 12 months ago

The problem is that the parser will identify "-x" as a scalar. In such a case I may check if this scalar starts with an hyphen but what it this is a valid, expected scalar starting with an hyphen? I cannot guess and make the difference...

sbaudoin commented 12 months ago

So if you could have a look at #59