{"id":14065338,"url":"https://github.com/jumanjihouse/pre-commit-hook-yamlfmt","last_synced_at":"2026-01-04T00:48:56.679Z","repository":{"id":39916625,"uuid":"250044942","full_name":"jumanjihouse/pre-commit-hook-yamlfmt","owner":"jumanjihouse","description":"YAML formatter for http://pre-commit.com","archived":false,"fork":false,"pushed_at":"2024-02-12T20:25:56.000Z","size":46,"stargazers_count":60,"open_issues_count":22,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-13T07:08:37.349Z","etag":null,"topics":["formatter","pre-commit","yamllint"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jumanjihouse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-25T17:24:42.000Z","updated_at":"2024-07-30T08:49:56.000Z","dependencies_parsed_at":"2024-05-28T00:30:02.038Z","dependency_job_id":"8fcf8b5f-eb35-4bf3-959d-fced6c73261d","html_url":"https://github.com/jumanjihouse/pre-commit-hook-yamlfmt","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanjihouse%2Fpre-commit-hook-yamlfmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanjihouse%2Fpre-commit-hook-yamlfmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanjihouse%2Fpre-commit-hook-yamlfmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanjihouse%2Fpre-commit-hook-yamlfmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jumanjihouse","download_url":"https://codeload.github.com/jumanjihouse/pre-commit-hook-yamlfmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228046129,"owners_count":17861101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formatter","pre-commit","yamllint"],"created_at":"2024-08-13T07:04:26.313Z","updated_at":"2026-01-04T00:48:56.638Z","avatar_url":"https://github.com/jumanjihouse.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# YAML formatter for pre-commit git hooks\n\nYAML formatter for [pre-commit](http://pre-commit.com).\n\nThis hook formats the indentation of YAML files and\noptionally aligns top-level colons.\u003cbr/\u003e\nIt uses [ruamel.yaml](https://yaml.readthedocs.io/en/latest/)\nto do the heavy lifting and preserve comments within YAML files.\n\n\u003c!--TOC--\u003e\n\n- [How-to](#how-to)\n  - [Configure pre-commit](#configure-pre-commit)\n    - [Use defaults](#use-defaults)\n    - [Combine with `yamllint`](#combine-with-yamllint)\n    - [Override defaults](#override-defaults)\n  - [Invoke pre-commit](#invoke-pre-commit)\n    - [On every commit](#on-every-commit)\n    - [On demand](#on-demand)\n- [Contributing](#contributing)\n- [Testing](#testing)\n- [License](#license)\n\n\u003c!--TOC--\u003e\n\n## How-to\n\n### Configure pre-commit\n\n#### Use defaults\n\nAdd to `.pre-commit-config.yaml` in your git repo:\n\n    - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt\n      rev: 0.2.1  # or other specific tag\n      hooks:\n          - id: yamlfmt\n\n:bulb: If a pre-commit hook changes a file,\nthe hook fails with a warning that files were changed.\n\nThe default settings are:\n\n- `mapping`: 4 spaces\n- `sequence`: 6 spaces\n- `offset`: 4 spaces\n- `colons`: do _not_ align top-level colons\n- `width`: None (use ruamel default)\n\nGiven this input:\n\n    foo:\n      bar:\n        - baz1\n        - baz2\n\nThe default settings result in this output:\n\n    ---\n    foo:\n        bar:\n            - baz1\n            - baz2\n\n\n#### Combine with `yamllint`\n\n`yamlfmt` only works with valid YAML files, so\nI recommend to use `yamllint` and `yamlfmt` together.\n\n    - repo: https://github.com/adrienverge/yamllint.git\n      rev: v1.21.0  # or higher tag\n      hooks:\n          - id: yamllint\n            args: [--format, parsable, --strict]\n\n    - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt\n      rev: 0.2.1  # or other specific tag\n      hooks:\n          - id: yamlfmt\n\n\n#### Override defaults\n\nAdd to `.pre-commit-config.yaml` in your git repo:\n\n    - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt\n      rev: 0.2.1  # or other specific tag\n      hooks:\n          - id: yamlfmt\n            args: [--mapping, '2', --sequence, '2', --offset, '0', --colons, --width, '150']\n\n\n### Invoke pre-commit\n\n#### On every commit\n\nIf you want to invoke the checks as a git pre-commit hook, run:\n\n    # Run on every commit.\n    pre-commit install\n\n\n#### On demand\n\nIf you want to run the checks on-demand (outside of git hooks), run:\n\n    # Run on-demand.\n    pre-commit run --all-files\n\nThe [test harness](TESTING.md) of this git repo uses this approach.\n\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md).\n\n\n## Testing\n\nPlease see [TESTING.md](TESTING.md).\n\n\n## License\n\nThe code in this repo is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumanjihouse%2Fpre-commit-hook-yamlfmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjumanjihouse%2Fpre-commit-hook-yamlfmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumanjihouse%2Fpre-commit-hook-yamlfmt/lists"}