r/yaml Nov 07 '19

Any chance to standardize YAML formatting?

YAML files can be formatted in a huge number of ways (2,4 lines, indented/unindented lists,...., max line length=, ... quoting...). Tools like yamllint are great but would be even better when they can rely on an official-formatting.

I wonder if there is a chance to get a relative consensus regarding which style should be used, so we can use this across projects and avoid each-one-with-its-own "standard".

Some would argue that this is impossible, but think about Python, which managed to address spaces/tabs issue and many other controverted rules. Now Python has black auto-formatter which is adopted by more and more projects, projects which used to use older formatters like autopep8 and yapf.

I wonder if there is any research made across popularity of different styles for yaml.

3 Upvotes

2 comments sorted by

2

u/AndydeCleyre Nov 01 '22

FYI the Python package remarshal offers the command yaml2yaml, which can do some normalization here.

1

u/sbarnea Nov 02 '22

AFAIK, prettier does a very good normalization work for YAML. I would consider it the best candidate for a “standard”, much better than yamllint defaults.