22
33commitlint checks if your commit messages meets the [ conventional commit format] ( https://www.conventionalcommits.org/en/v1.0.0/ )
44
5- [ ![ PkgGoDev] ( https://pkg.go.dev/badge/github.com/conventionalcommit/parser )] ( https://pkg.go.dev/github.com/conventionalcommit/parser )
5+ [ ![ PkgGoDev] ( https://pkg.go.dev/badge/github.com/conventionalcommit/commitlint )] ( https://pkg.go.dev/github.com/conventionalcommit/commitlint )
66
77#### Table of Contents
88
9- + [ Installation] ( #installation )
10- + [ Enable in Git Repo] ( #enable-in-git-repo )
11- + [ Benefits using commitlint] ( #benefits-using-commitlint )
12- + [ Commit Types] ( #commit-types )
13- + [ Library] ( #library )
9+ - [ Installation] ( #installation )
10+ - [ Releases] ( #releases )
11+ - [ Using go] ( #using-go )
12+ - [ Enable in Git Repo] ( #enable-in-git-repo )
13+ - [ Test] ( #test )
14+ - [ Custom config for each repo] ( #custom-config-for-each-repo )
15+ - [ Benefits using commitlint] ( #benefits-using-commitlint )
16+ - [ Commit Types] ( #commit-types )
17+ - [ Library] ( #library )
1418 - [ Config Precedence] ( #config-precedence )
1519 - [ Message Precedence] ( #message-precedence )
1620 - [ Default Config] ( #default-config )
17- + [ License] ( #license )
21+ - [ License] ( #license )
1822
1923### Installation
2024
21- ``` bash
22- # Install commitlint
23- go install github.com/conventionalcommit/commitlint/cmd/commitlint@latest
25+ #### Releases
2426
25- # test commitlint - error case
26- echo " fear: do not fear for commit message" | commitlint lint
27- # will show error message like
28- # ❌ type: 'fear' is not allowed, you can use one of [feat fix docs style refactor perf test build ci chore revert merge]
27+ Download binary from [ releases] ( https://github.com/conventionalcommit/commitlint/releases ) and add the path to your ` PATH `
2928
30- # test commitlint - valid case
31- echo " feat: good commit message" | commitlint lint
32- # ✓ commit message
29+ #### Using go
30+
31+ ``` bash
32+ # Install commitlint
33+ go install github.com/conventionalcommit/commitlint@latest
3334```
3435
3536### Enable in Git Repo
3637
3738``` bash
3839# enable for single repo
39- commitlint create hook # from repo directory
40+ commitlint init # from repo directory
4041
4142# enable for globally for all repos
42- commitlint create hook --global
43+ commitlint init --global
4344```
4445
46+ ### Test
47+
48+ ``` bash
49+ # invalid commit message
50+ echo " fear: do not fear for commit message" | commitlint lint
51+ # ❌ type-enum: type 'fear' is not allowed, you can use one of [feat fix docs style refactor perf test build ci chore revert merge]
52+
53+ # valid commit message
54+ echo " feat: good commit message" | commitlint lint
55+ # ✔ commit message
56+ ```
57+
58+ ### Custom config for each repo
59+
60+ - run ` commitlint create config ` in repo root directory
61+ - this will create ` commitlint.yaml ` in that directory
62+ - you can customise the config to your need
63+
4564### Benefits using commitlint
4665
4766- [ Why Use Conventional Commits] ( https://www.conventionalcommits.org/en/v1.0.0/#why-use-conventional-commits )
4867
4968### Commit Types
5069
51- Commonly used commit types from [ Conventional Commit Types] ( https://github.com/commitizen/conventional-commit-types )
70+ Commonly used commit types from [ Conventional Commit Types] ( https://github.com/commitizen/conventional-commit-types )
5271
5372| Type | Description |
5473| :---------| :---------------------------------------------------------------------------------|
@@ -82,19 +101,28 @@ commitlint create hook --global
82101#### Default Config
83102
84103``` yaml
85- header :
86- min-length :
104+ formatter : default
105+ rules :
106+ header-min-length :
87107 enabled : true
88- type : error
89- value : 10
90- max-length :
108+ severity : error
109+ argument : 10
110+ header- max-length :
91111 enabled : true
92- type : error
93- value : 50
94- types :
112+ severity : error
113+ argument : 50
114+ body-max-line-length :
95115 enabled : true
96- type : error
97- value :
116+ severity : error
117+ argument : 72
118+ footer-max-line-length :
119+ enabled : true
120+ severity : error
121+ argument : 72
122+ type-enum :
123+ enabled : true
124+ severity : error
125+ argument :
98126 - feat
99127 - fix
100128 - docs
@@ -107,25 +135,8 @@ header:
107135 - chore
108136 - revert
109137 - merge
110- scopes :
111- enabled : false
112- type : error
113- value : []
114- body :
115- can-be-empty : true
116- max-line-length :
117- enabled : true
118- type : error
119- value : 72
120- footer :
121- can-be-empty : true
122- max-line-length :
123- enabled : true
124- type : error
125- value : 72
126138` ` `
127139
128140### License
129141
130142All packages are licensed under [MIT License](https://github.com/conventionalcommit/commitlint/tree/master/LICENSE.md)
131-
0 commit comments