Migrating from commitlint
1. Replace the hook and the CI
In the commit-msg hook, replace commitlint --edit "$1" with relizy commitlint --edit "$1", or run relizy commitlint --install (see Commit linting). In CI, replace commitlint --from <base> --to HEAD with relizy commitlint: the range of the pull or merge request is found automatically.
2. Move the config
Most of a commitlint config disappears: the types, the scopes and the bump come from your Relizy config. Move what remains to the commitlint key of relizy.config.ts, then remove commitlint:
pnpm remove @commitlint/cli @commitlint/config-conventional @commitlint/types commitlint-plugin-function-rules
rm commitlint.config.* .commitlintrc*The rules take the ESLint format, 'error' or ['error', value], and accept the commitlint tuples [2, 'always', value] (see levels and values). Copy a tuple as is only when its value means the same in Relizy (header-max-length): the value of type-enum adds types to your Relizy types instead of restricting them, the value of scope-enum is ignored (the scopes come from your packages and commitlint.scopes), commitlint's scope-empty: [2, 'never'] (scope required) is 'scope-required': 'error', and the subject-case tuple of config-conventional turns on a rule that Relizy leaves off.
Rules of @commitlint/config-conventional
| commitlint rule | Relizy equivalent |
|---|---|
type-enum | type-enum, from your Relizy types |
type-case, type-empty, subject-empty, header-trim | header-format |
subject-case | subject-case, off by default and narrower: it only rejects a subject starting with an uppercase letter (not an acronym) |
subject-full-stop | subject-full-stop |
header-max-length (100) | header-max-length, 500 by default: set ['error', 100] to keep the limit |
body-leading-blank | body-leading-blank, an error instead of a warning |
body-max-line-length, footer-max-line-length | None: the changelogs have no line length limit |
footer-leading-blank | None: the footer is the last paragraph of the message |
Other common rules:
| commitlint rule | Relizy equivalent |
|---|---|
scope-enum | scope-enum, from your packages, scopeMap and commitlint.scopes |
scope-case | header-format (no spaces) and scope-enum |
scope-empty | scope-required, with 'when-bumping' to require it only on the commits that bump a version |
| Any other rule | A custom rule |
Relizy adds rules commitlint has no equivalent for: scope-matches-files, subject-meaningful, body-no-headings, body-markdown, body-changelog-lint, body-breaking-change, no-breaking and no-ai-attribution.
Function rules
commitlint-plugin-function-rules rules become custom rules: the commit has the same field names and the [valid, message] return value is accepted, so the function can be copied as is. The value argument becomes context.value.
// commitlint.config.ts (before): the types and the scopes copied by hand
import type { UserConfig } from '@commitlint/types'
import * as functionRules from 'commitlint-plugin-function-rules'
export default {
extends: ['@commitlint/config-conventional'],
plugins: [functionRules],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'perf', 'refactor', 'docs', 'build', 'types', 'chore', 'test', 'ci']],
'scope-enum': [2, 'always', ['core', 'nuxt', 'ci', 'deps', 'release']],
'header-max-length': [2, 'always', 200],
'function-rules/subject-min-length': [2, 'always', ({ subject }) => [/^\[[A-Z]+-\d+\] \S+ \S+/.test(subject ?? ''), 'Start with the ticket, then describe the change']],
},
} satisfies UserConfig// relizy.config.ts (after): the types and the package scopes are built in
import { defineConfig } from 'relizy'
export default defineConfig({
commitlint: {
scopes: ['ci', 'deps', 'release'],
rules: { 'header-max-length': ['error', 200] },
customRules: {
'subject-ticket': ({ subject }) => [/^\[[A-Z]+-\d+\] \S+ \S+/.test(subject), 'Start with the ticket, then describe the change'],
},
},
})Differences
- Reverts: commitlint ignores the
Revert "..."messages of git, Relizy requires a conventional commit:revert: <reverted header>with areverttype in your Relizytypes, or a commit of the type of the change, e.g.fix(core): revert the parser change. - Stricter defaults:
subject-meaningful,no-ai-attributionand the body rules may report commits commitlint accepted. Tune or disable them incommitlint.rules. - Not supported:
extendsand shareable configs (the defaults of Relizy replace@commitlint/config-conventional), commitlint plugins (write custom rules), and the prompt of@commitlint/cz-commitlint.