commitlint

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 4 Imported by: 0

README

commitlint

commitlint checks if your commit messages meets the conventional commit format

PkgGoDev

Table of Contents
Installation
Releases

Download binary from releases and add it to your PATH

Using go
go install github.com/conventionalcommit/commitlint@latest
Enable in Git Repo
  • enable for a single repository, cd to repository directory

    commitlint init
    
  • enable globally for all repositories

    commitlint init --global
    
Quick Test
# invalid commit message
echo "fear: do not fear for commit message" | commitlint lint
# ❌ type-enum: type 'fear' is not allowed, you can use one of [feat fix docs style refactor perf test build ci chore revert merge]

# valid commit message
echo "feat: good commit message" | commitlint lint
# ✔ commit message
Custom config for each repo
  • run commitlint create config in repo root directory

    this will create commitlint.yaml in that directory, you can customise the config to your need

  • run commitlint verify to verify if config is valid or not

Benefits of using commitlint
Commit Types

Commonly used commit types from Conventional Commit Types

Type Description
feat A new feature
fix A bug fix
docs Documentation only changes
style Changes that do not affect the meaning of the code (white-space, formatting etc)
refactor A code change that neither fixes a bug nor adds a feature
perf A code change that improves performance
test Adding missing tests or correcting existing tests
build Changes that affect the build system or external dependencies
ci Changes to our CI configuration files and scripts
chore Other changes that don't modify src or test files
revert Reverts a previous commit
merge Merges a branch
Library
Config Precedence
  • commitlint.yaml config file in current directory
  • config file passed with --config command-line argument
  • default config
Message Precedence
  • stdin stream
  • commit message file passed with --message command-line argument
  • .git/COMMIT_EDITMSG in current directory
Default Config
formatter: default
rules:
    header-min-length:
        enabled: true
        severity: error
        argument: 10
    header-max-length:
        enabled: true
        severity: error
        argument: 50
    body-max-line-length:
        enabled: true
        severity: error
        argument: 72
    footer-max-line-length:
        enabled: true
        severity: error
        argument: 72
    type-enum:
        enabled: true
        severity: error
        argument:
            - feat
            - fix
            - docs
            - style
            - refactor
            - perf
            - test
            - build
            - ci
            - chore
            - revert
            - merge
License

All packages are licensed under MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd contains commitlint cli
Package cmd contains commitlint cli
Package config contains helpers, defaults for linter
Package config contains helpers, defaults for linter
Package formatter contains lint result formatters
Package formatter contains lint result formatters
Package hook contains git hook related informations
Package hook contains git hook related informations
Package lint provides a simple linter for conventional commits
Package lint provides a simple linter for conventional commits
Package message contains commit message
Package message contains commit message
Package rule contains lint rules
Package rule contains lint rules

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL