|
| 1 | +# commitlint |
| 2 | + |
| 3 | +commitlint checks if your commit messages meets the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/) |
| 4 | + |
| 5 | +[](https://pkg.go.dev/github.com/conventionalcommit/parser) |
| 6 | + |
| 7 | +### Installation |
| 8 | + |
| 9 | +```bash |
| 10 | +# Install commitlint |
| 11 | +go install github.com/conventionalcommit/commitlint/cmd/commitlint@latest |
| 12 | + |
| 13 | +# test commitlint - error case |
| 14 | +echo "fear: do not fear for commit message" | commitlint lint |
| 15 | +# will show error message like |
| 16 | +# ❌ type: 'fear' is not allowed, you can use one of [feat fix docs style refactor perf test build ci chore revert merge] |
| 17 | + |
| 18 | +# test commitlint - valid case |
| 19 | +echo "feat: good commit message" | commitlint lint |
| 20 | +# ✓ commit message |
| 21 | +``` |
| 22 | + |
| 23 | +### Enable in Git Repo |
| 24 | + |
| 25 | +```bash |
| 26 | +# enable for single repo |
| 27 | +commitlint create hook # from repo directory |
| 28 | + |
| 29 | +# enable for globally for all repos |
| 30 | +commitlint create hook --global |
| 31 | +``` |
| 32 | + |
| 33 | +### Benefits using commitlint |
| 34 | + |
| 35 | +- [Why Use Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#why-use-conventional-commits) |
| 36 | + |
| 37 | +### Commit Types |
| 38 | + |
| 39 | + Commonly used commit types from [Conventional Commit Types](https://github.com/commitizen/conventional-commit-types) |
| 40 | + |
| 41 | +| Type | Description | |
| 42 | +|:---------|:---------------------------------------------------------------------------------| |
| 43 | +| feat | A new feature | |
| 44 | +| fix | A bug fix | |
| 45 | +| docs | Documentation only changes | |
| 46 | +| style | Changes that do not affect the meaning of the code (white-space, formatting etc) | |
| 47 | +| refactor | A code change that neither fixes a bug nor adds a feature | |
| 48 | +| perf | A code change that improves performance | |
| 49 | +| test | Adding missing tests or correcting existing tests | |
| 50 | +| build | Changes that affect the build system or external dependencies | |
| 51 | +| ci | Changes to our CI configuration files and scripts | |
| 52 | +| chore | Other changes that don't modify src or test files | |
| 53 | +| revert | Reverts a previous commit | |
| 54 | +| merge | Merges a branch | |
| 55 | + |
| 56 | +### Library |
| 57 | + |
| 58 | +#### Config Precedence |
| 59 | + |
| 60 | +- `commitlint.yaml` config file in current directory |
| 61 | +- config file passed with `--config` command-line argument |
| 62 | +- [default config](#default-config) |
| 63 | + |
| 64 | +#### Message Precedence |
| 65 | + |
| 66 | +- `stdin` stream |
| 67 | +- commit message file passed with `--message` command-line argument |
| 68 | +- `.git/COMMIT_EDITMSG` in current directory |
| 69 | + |
| 70 | +#### Default Config |
| 71 | + |
| 72 | +```yaml |
| 73 | +header: |
| 74 | + min-length: |
| 75 | + enabled: true |
| 76 | + type: error |
| 77 | + value: 10 |
| 78 | + max-length: |
| 79 | + enabled: true |
| 80 | + type: error |
| 81 | + value: 50 |
| 82 | + types: |
| 83 | + enabled: true |
| 84 | + type: error |
| 85 | + value: |
| 86 | + - feat |
| 87 | + - fix |
| 88 | + - docs |
| 89 | + - style |
| 90 | + - refactor |
| 91 | + - perf |
| 92 | + - test |
| 93 | + - build |
| 94 | + - ci |
| 95 | + - chore |
| 96 | + - revert |
| 97 | + - merge |
| 98 | + scopes: |
| 99 | + enabled: false |
| 100 | + type: error |
| 101 | + value: [] |
| 102 | +body: |
| 103 | + can-be-empty: true |
| 104 | + max-line-length: |
| 105 | + enabled: true |
| 106 | + type: error |
| 107 | + value: 72 |
| 108 | +footer: |
| 109 | + can-be-empty: true |
| 110 | + max-line-length: |
| 111 | + enabled: true |
| 112 | + type: error |
| 113 | + value: 72 |
| 114 | +``` |
| 115 | +
|
| 116 | +### License |
| 117 | +
|
| 118 | +All packages are licensed under [MIT License](https://github.com/conventionalcommit/commitlint/tree/master/LICENSE.md) |
| 119 | +
|
0 commit comments