Commitlink hook for pre-commit

Configuration

  • Create your commitlint config file in the repo's root, as explained in Commitlint docs.
  • Add the following to your .pre-commit-config.yaml:
    - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
      sha: v1.0.0
      hooks:
          - id: commitlint
            stages: [commit-msg]
    
  • If you are using one of Commitlint's shared configurations, add it to the additional_dependencies parameter of the hooks, i.e:
    - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
      sha: v1.0.0
      hooks:
          - id: commitlint
            stages: [commit-msg]
            additional_dependencies: ['@commitlint/config-angular']
    
  • Install the commit-msg hook in your project repo:
    pre-commit install --hook-type commit-msg