language-formatters-pre-commit-hooks
language-formatters-pre-commit-hooks copied to clipboard
Preserve comments in yaml arrays.
trafficstars
So I have for example this file:
val1: adsf
val2: [
1,
2,
# comment
3,
4,
]
but when the formatter runs, I get this output:
val1: adsf
val2: [1, 2, 3, 4]
Is it possible to not compact lists into a one liner, and to keep comments? maybe we can have a setting that keeps new lines, which might prevent this from collapsing? This also happens with this yaml file:
# comments are allowed in yaml
{
val1: adsf,
# some comment
val2: [1, 2, 3, 4]
}
which is converted to this:
# comments are allowed in yaml
{val1: adsf, val2: [1, 2, 3, 4]}
This is my config:
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.0.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '1']