Shared commitlint config that extends @commitlint/config-conventional, which enforces Conventional Commits.
@commitlint/cli21 is a peer dependency and must be installed in your project.
pnpm add --save-dev @commitlint/cli @dnd-mapp/config-commitlintRe-export the config from a commitlint.config.js file in your project root.
export { default } from '@dnd-mapp/config-commitlint';To add your own rules, spread the config into your own.
import config from '@dnd-mapp/config-commitlint';
export default {
...config,
rules: {
...config.rules,
'scope-enum': [2, 'always', ['api', 'web']],
},
};The config ships with type declarations. It is typed as a commitlint UserConfig, so it works in a commitlint.config.ts file.
The config uses every rule from @commitlint/config-conventional with two changes.
| Rule | Setting | Reason |
|---|---|---|
header-max-length |
72 |
Keeps subject lines readable in git log |
body-max-line-length |
72 |
Follows the common Git convention for bodies |
Run commitlint from a commit-msg hook to check every commit message. This example uses Lefthook.
pnpm add --save-dev lefthookThen add a lefthook.yaml file to your project root and run pnpm exec lefthook install.
commit-msg:
jobs:
- name: commitlint
run: pnpm exec commitlint --edit {1}