anoop-commitlint-config
v0.2.0
Published
Centralized commitlint configuration and CLI for OVHcloud Manager projects
Readme
@ovhcloud/manager-commitlint-config
Centralized commitlint configuration and CLI for OVHcloud Manager projects. Provides one source of truth for commit-message rules across every Manager repository.
What you get
- A shared rules object (extends
@commitlint/config-conventional). - A
manager-commitlintCLI that runs commitlint with the bundled config — or with a localcommitlint.config.*when one exists. @commitlint/cliand@commitlint/config-conventionalbundled as runtime dependencies, so consumers install one package, not three.
Quickstart
1. Install
pnpm add -D @ovhcloud/manager-commitlint-config2. Wire up the git hook
.githooks/commit-msg:
#!/bin/sh
pnpm exec manager-commitlint --edit "$1"Make it executable, and point git at the directory:
chmod +x .githooks/commit-msg
git config core.hooksPath .githooks(Most Manager repos already have a prepare script in package.json that sets core.hooksPath for you.)
3. (Optional) Override or extend rules
Drop one of commitlint.config.{js,mjs,cjs,ts} at the repo root. The CLI auto-detects it and hands off to commitlint, which uses its own resolver — so any of those four extensions works regardless of the bundle format the package ships.
When a local config is present, only that file is used: it must reference this package to inherit the shared rules. Two equivalent styles:
A. extends (idiomatic commitlint):
// commitlint.config.mjs
export default {
extends: ['@ovhcloud/manager-commitlint-config'],
rules: {
'scope-enum': [2, 'always', ['billing', 'auth', 'iam']],
},
};extends tells commitlint to load the base config and merge your rules on top. Use this when you only need to add or tweak rules.
B. spread (when you need full control):
// commitlint.config.mjs
import base from '@ovhcloud/manager-commitlint-config';
export default {
...base,
rules: {
...base.rules,
'scope-enum': [2, 'always', ['billing', 'auth', 'iam']],
'header-max-length': [2, 'always', 120], // override a base rule
},
};Use this when you want to inspect or replace non-rules fields (e.g. ignores, parserPreset, formatter). The ...base.rules spread is required — otherwise your rules object replaces the base instead of extending it.
Precedence
| Situation | What runs |
|--------------------------------------------|--------------------------------------------|
| No commitlint.config.* in the repo | Bundled config (dist/commitlint.config.mjs) |
| Local commitlint.config.{js,mjs,cjs,ts} | Local file (and whatever it extends / spreads) |
The hook command (pnpm exec manager-commitlint --edit "$1") stays the same in both cases.
Common overrides
- Restrict scopes —
'scope-enum': [2, 'always', ['x', 'y']] - Loosen header length —
'header-max-length': [2, 'always', 120] - Downgrade a rule to a warning — change severity from
2to1, or0to disable. - Skip more commit prefixes than
fixup!— extendignoresin the spread style:ignores: [...base.ignores, (c) => c.startsWith('wip:')],
Zero-install usage (pnpm dlx)
Once the package is published, repos can skip the dependency install entirely:
#!/bin/sh
pnpm dlx @ovhcloud/manager-commitlint-config --edit "$1"The CLI behaves identically. Override files are still picked up from the consumer repo.
Rules enforced
| Rule | Severity | Notes |
|---|---|---|
| extends: ["@commitlint/config-conventional"] | — | base ruleset |
| type-enum | error | build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test, sync, release, merge |
| scope-empty / scope-case | error / error | scope is required and lowercase |
| header-max-length | error | 100 |
| body-leading-blank / footer-leading-blank | error | blank line required before body/footer |
| signed-off-by | error | Signed-off-by: footer required |
| references-empty | warning | ref: #MANAGER-… recommended |
| ignores | — | commits starting with fixup! are skipped |
See commitlint rules reference for the full grammar.
Development
pnpm install # also runs the build via `prepare`
pnpm build # tsc → dist/, then emit dist/commitlint.config.mjs
pnpm test # vitest
pnpm test:watch # vitest in watch mode