Skip to content

Commit 3ebd123

Browse files
docs: update README
1 parent d77bb75 commit 3ebd123

File tree

1 file changed

+102
-10
lines changed

1 file changed

+102
-10
lines changed

README.md

Lines changed: 102 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ commitlint checks if your commit message meets the [conventional commit format](
2323
- [Using go](#using-go)
2424
- [Setup](#setup)
2525
- [Manual](#manual)
26+
- [Remove](#remove)
2627
- [Quick Test](#quick-test)
2728
- [Commands](#commands)
2829
- [config](#config)
@@ -34,6 +35,10 @@ commitlint checks if your commit message meets the [conventional commit format](
3435
- [debug](#debug)
3536
- [Default Config](#default-config)
3637
- [Commit Types](#commit-types)
38+
- [Ignore Patterns](#ignore-patterns)
39+
- [Default Ignore Patterns](#default-ignore-patterns)
40+
- [Custom Ignore Patterns](#custom-ignore-patterns)
41+
- [Disabling Default Ignores](#disabling-default-ignores)
3742
- [Available Rules](#available-rules)
3843
- [Available Formatters](#available-formatters)
3944
- [Extensibility](#extensibility)
@@ -75,13 +80,29 @@ commitlint init --global --hookspath /path/to/hooks
7580

7681
### Manual
7782

78-
- run `commitlint hook create` to create `.commitlint/hooks` containing git hooks
79-
- pass `--hookspath` to customize the hooks output path
83+
- run `commitlint hook` to create `.commitlint/hooks` containing git hooks
84+
- pass `--hookspath` or `-p` to customize the hooks output path
8085
- To enable in single repo
8186
- run `git config core.hooksPath /path/to/.commitlint/hooks`
8287
- To enable globally
8388
- run `git config --global core.hooksPath /path/to/.commitlint/hooks`
8489

90+
### Remove
91+
92+
- To remove hooks from a single repository
93+
94+
```bash
95+
commitlint remove
96+
```
97+
98+
- To remove hooks globally
99+
100+
```bash
101+
commitlint remove --global
102+
```
103+
104+
Both commands ask for confirmation before unsetting `core.hooksPath` in git config. Hook files are left intact.
105+
85106
## Quick Test
86107

87108
- Valid commit message
@@ -102,9 +123,11 @@ echo "fear: do not fear for commit message" | commitlint lint
102123

103124
### config
104125

105-
- To create config file, run `commitlint config create` this will create `commitlint.yaml`
126+
- To create a config file, run `commitlint config create`, this will create `.commitlint.yaml` with only the enabled rules and their settings (compact format)
127+
128+
- To create a config file with **all** rules and settings written out (including disabled ones), run `commitlint config create --all`
106129

107-
- To validate config file, run `commitlint config check --config=/path/to/conf.yaml`
130+
- To validate a config file, run `commitlint config check /path/to/conf.yaml`
108131

109132
### lint
110133

@@ -136,7 +159,9 @@ To lint a message, you can use any one of the following
136159

137160
### hook
138161

139-
- To create hook files, run `commitlint hook create`
162+
- To create hook files, run `commitlint hook`
163+
- pass `--hookspath` or `-p` to customize the hooks output directory
164+
- pass `--replace` or `-r` to overwrite existing hook files
140165

141166
### debug
142167

@@ -147,7 +172,7 @@ To lint a message, you can use any one of the following
147172
## Default Config
148173

149174
```yaml
150-
min-version: v0.9.0
175+
min-version: v0.11.0
151176
formatter: default
152177
rules:
153178
- header-min-length
@@ -157,15 +182,20 @@ rules:
157182
- type-enum
158183
severity:
159184
default: error
185+
rules: {}
160186
settings:
161187
body-max-line-length:
162-
argument: 72
188+
argument: 100
189+
flags: {}
163190
footer-max-line-length:
191+
argument: 100
192+
flags: {}
193+
header-max-length:
164194
argument: 72
195+
flags: {}
165196
header-min-length:
166197
argument: 10
167-
header-max-length:
168-
argument: 50
198+
flags: {}
169199
type-enum:
170200
argument:
171201
- feat
@@ -179,6 +209,9 @@ settings:
179209
- ci
180210
- chore
181211
- revert
212+
flags: {}
213+
disable-default-ignores: false
214+
ignores: []
182215
```
183216
184217
### Commit Types
@@ -199,6 +232,53 @@ Commonly used commit types from [Conventional Commit Types](https://github.com/c
199232
| chore | Other changes that don't modify src or test files |
200233
| revert | Reverts a previous commit |
201234
235+
## Ignore Patterns
236+
237+
commitlint automatically skips linting for commit messages generated by git (merges, reverts, fixups, etc.).
238+
If the **first line** of a commit message matches any ignore pattern, linting is skipped entirely.
239+
240+
### Default Ignore Patterns
241+
242+
The following patterns are enabled by default
243+
(source: [`config/default.go`](config/default.go)):
244+
245+
| Pattern | Matches |
246+
| :--- | :--- |
247+
| `^Merge pull request #\d+` | GitHub pull request merges |
248+
| `^Merge .+ into .+` | Generic merge (X into Y) |
249+
| `^Merge branch '.+'` | `git merge` branch |
250+
| `^Merge tag '.+'` | `git merge` tag |
251+
| `^Merge remote-tracking branch '.+'` | `git merge` remote-tracking branch |
252+
| `^Merged .+ (in\|into) .+` | Azure DevOps / Bitbucket merged |
253+
| `^Merged PR #?\d+` | Azure DevOps pull request |
254+
| `^(R\|r)evert ` | `git revert` |
255+
| `^(R\|r)eapply ` | `git reapply` |
256+
| `^(amend\|fixup\|squash)! ` | `git commit --fixup/--squash/--amend` |
257+
| `^Automatic merge` | Automatic merges |
258+
| `^Auto-merged .+ into .+` | Auto-merged branches |
259+
| `^Initial commit$` | Initial commit (exact match) |
260+
261+
### Custom Ignore Patterns
262+
263+
Add your own patterns in the config file under `ignores:`. User-defined patterns are
264+
**additive**, they are checked alongside the built-in defaults.
265+
266+
```yaml
267+
ignores:
268+
- "^WIP "
269+
- "^TICKET-\\d+"
270+
```
271+
272+
### Disabling Default Ignores
273+
274+
If you want **only** your custom patterns (no built-in defaults), set `disable-default-ignores: true`:
275+
276+
```yaml
277+
disable-default-ignores: true
278+
ignores:
279+
- "^WIP "
280+
```
281+
202282
## Available Rules
203283

204284
The list of available lint rules
@@ -255,12 +335,24 @@ Total 1 errors, 0 warnings, 0 other severities
255335

256336
Place `.commitlint.yaml` file in repo root directory. linter follows [config precedence](#precedence).
257337

258-
To create a sample config, run `commitlint config create`
338+
To create a sample config, run `commitlint config create` (or `commitlint config create --all` to include all available settings)
259339

260340
- How can I skip lint check for a commit?
261341

262342
use `--no-verify` flag with `git commit` which skips commit hooks
263343

344+
- How does commitlint handle merge / revert commits?
345+
346+
commitlint ships with [built-in ignore patterns](#default-ignore-patterns) that
347+
automatically skip linting for merge commits, reverts, fixups, squashes, and other
348+
git-generated messages. You can add your own patterns with the `ignores` config key,
349+
or disable the defaults with `disable-default-ignores: true`.
350+
351+
- Can I use the old `version` config key?
352+
353+
Yes. The `version` key is still accepted for backward compatibility, but new config
354+
files should use `min-version` instead.
355+
264356
## License
265357

266358
All packages are licensed under [MIT License](LICENSE.md)

0 commit comments

Comments
 (0)