adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.83k stars 269 forks source link

Add `check-keys` option to `quoted-strings` rule #618

Closed HenryGessau closed 9 months ago

HenryGessau commented 9 months ago

Closes #617

coveralls commented 9 months ago

Coverage Status

coverage: 99.414% (+0.09%) from 99.322% when pulling 9ef0479d948d16729f3927ffd316918c2b608105 on HenryGessau:key-quoted-strings into e5fdfd2ae59b9e5774beaec3aaa673850bc29164 on adrienverge:master.

HenryGessau commented 9 months ago

I don't see the need for a new rule key-quoted-strings just for keys, moreover in such a scenario the rule quoted-strings should then be renamed value-quoted-strings. In my opinion the required quote type will always be the same (nobody wants ' for keys and " for values), so what about using quoted-strings for all quoted strings (whatever their position)? It would also avoid a lot of code duplication.

I came across a project where they want quotes to be required if there is a $ in value strings, but not quoted for $ in key strings. That was the only reason why I proposed support for separate quoting rules for keys, but now that I think about it, that's a rather esoteric style. (If there is real demand, such styles could be perhaps supported later by adding keys-extra-required and values-extra-required options to the existing rule.)

I'll pare this PR down to remove the key-quoted-strings rule. And, yes, I will squash the commits.

HenryGessau commented 9 months ago

@adrienverge I have updated this for your review.

HenryGessau commented 9 months ago

@adrienverge I don't see how the CI errors are related to my change?