Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 1.96 KB

File metadata and controls

70 lines (51 loc) · 1.96 KB

pre-commit hooks

Miscellaneous hooks for pre-commit.

Hooks available

  • check-zero-width-spaces - Forbid files which have one or more zero width spaces (U+200B).

  • hadolint - Run Hadolint on Dockerfiles.

  • nomad-fmt - Run nomad fmt on Nomad manifests.

  • packer-validate - Run packer validate on JSON files.

How to install

  1. Install dependencies:

  2. Install the pre-commit hook globally:

    pre-commit init-templatedir -t pre-commit ~/.git-template
  3. Create the .pre-commit-config.yaml file:

    cd /path/to/my/repo/
    vim .pre-commit-config.yaml

    Tip: use the example from the next section as a start point.

  4. Run:

    pre-commit run -a

Full example

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/flaudisio/pre-commit-hooks
    rev: v0.11.1
    hooks:
      - id: check-zero-width-spaces
      - id: hadolint
        args:
          - --config .hadolint.strict.yaml
          - --ignore DL3013
          - --ignore DL3018
          - --trusted-registry registry.example.com:5000
        exclude: ^cookiecutter/.+/Dockerfile$
      - id: packer-validate
        files: ^templates/.+\.json$

License

MIT.