commitlint

command module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 3 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
Benefits of using conventional commit
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
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
Commands
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

Verify config file
  • run commitlint verify to verify if config is valid or not (according to config precedence)

  • run commitlint verify --config=/path/to/conf.yamlto verify given config file

Rules

The list of available lint rules

name argument flags description
header-min-length int n/a checks the min length of header (first line)
header-max-length int n/a checks the max length of header (first line)
body-max-line-length int n/a checks the max length of each line in body
footer-max-line-length int n/a checks the max length of each line in footer
type-enum []string n/a restrict type to given list of string
scope-enum []string allow-empty: bool restrict scope to given list of string
type-min-length int n/a checks the min length of type
type-max-length int n/a checks the max length of type
scope-min-length int n/a checks the min length of scope
scope-max-length int n/a checks the max length of scope
description-min-length int n/a checks the min length of description
description-max-length int n/a checks the max length of description
body-min-length int n/a checks the min length of body
body-max-length int n/a checks the max length of body
footer-min-length int n/a checks the min length of footer
footer-max-length int n/a checks the max length of footer
type-charset string n/a restricts type to given charset
scope-charset string n/a restricts scope to given charset
Library
Config Precedence
  • commitlint.yaml config file in current directory
  • config file passed with --config command-line argument
  • default config
Commit Message Precedence
  • stdin pipe 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