pre-commit-hooks: Make yaml check error on duplicate keys

We make this mistake all the time:

# foo.yaml

'key1': false
'key2': true
'key1': true

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 17 (11 by maintainers)

Most upvoted comments

I am not sure about check-yaml implementation but I am using the yamllint linter which is probably the most advanced, and it does catch duplicate keys.

  - repo: https://github.com/adrienverge/yamllint.git
    rev: v1.11.1
    hooks:
      - id: yamllint
        files: \.(yaml|yml)$

Obviously that this should not be taken as a reason not to fix it official pre-commit hooks. I would myself support getting yamllint into main repo, maybe even removing the check-yaml one.