adapter-commitlint
Generates a .commitlintrc.json config file for commit message linting. This is a setup-only adapter: commitlint is invoked by husky, not by lodestar directly.
Package: @retemper/lodestar-adapter-commitlint
Managed file: .commitlintrc.json
Config Options
| Option | Type | Description |
|---|---|---|
extends | string[] | Shareable configs to extend -- e.g., '@commitlint/config-conventional' |
rules | Record<string, unknown> | Custom rules -- e.g., {"type-enum": [2, "always", ["feat", "fix", "chore"]]} |
All options are optional. Calling commitlintAdapter() with no arguments produces an empty config.
Example
ts
import { commitlintAdapter } from '@retemper/lodestar-adapter-commitlint';
commitlintAdapter({
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'chore', 'docs', 'refactor', 'test']],
'subject-case': [2, 'always', 'lower-case'],
},
});How verifySetup Works
- Checks that
.commitlintrc.jsonexists inrootDir. - Reads the file content and compares it against the JSON that lodestar config produces.
- Returns a missing violation if the file does not exist.
- Returns a drift violation (with a diff of expected vs actual) if the content does not match.
- Returns no violations if
.commitlintrc.jsonmatches.
Drift means the .commitlintrc.json file was manually edited or overwritten by another tool, so it no longer reflects the lodestar config. Running lodestar check --fix regenerates the file to resolve the violation.
Note: This adapter does not implement
check(). commitlint is triggered by husky git hooks (e.g.,commit-msg), not bylodestar check.