Starting in v0.7.1, yamlfmt
can be used as a hook for the popular pre-commit tool. To include a yamlfmt
hook in your pre-commit
config, add the following to the repos
block in your .pre-commit-config.yaml
:
- repo: https://github.com/google/yamlfmt
rev: v0.14.0
hooks:
- id: yamlfmt
When running yamlfmt with the pre-commit
hook, the only way to configure it is through a .yamlfmt
configuration file in the root of the repo or a system wide config directory (see Configuration File docs).
If you would prefer to manage your yamlfmt
installation yourself, you can have the hook use your installed yamlfmt
binary instead. As long as yamlfmt
is in your PATH, you can override the language
setting to system
.
- repo: https://github.com/google/yamlfmt
rev: v0.14.0
hooks:
- id: yamlfmt
language: system