pre-commit-hook-yamlfmt
pre-commit-hook-yamlfmt copied to clipboard
Adds ability to sort keys alphabetically and preserve comments
This PR adds the ability to sort yaml keys (-k
/--sort_keys
command line) while retaining some comments. A CI test is also added illustrating the retention of comments.
When keys need to be moved around, some comments may be mistakenly left in their place, for example see https://stackoverflow.com/questions/53849036/how-to-keep-comments-in-ruamel which explains why the comments may be dissociated.
Fixes: #40
We really need this :pray:
/cc @jumanjiman
I'm also interested in this feature! Not sure if the author is accepting PRs at the moment.
@cristicalin one thought on a trivial addition - I'd be interested in a "top keys" option, which allows certain keys to retain priority during sort. Happy to contribute this if you're still working on this feature.