Basic Configuration
This feature allows you to set up commitlint with a basic configuration that extends the conventional commit rules. This ensures that your commit messages follow a standard format.
{
"extends": ["@commitlint/config-conventional"]
}
Custom Rules
You can define custom rules for commit messages. In this example, the 'type-enum' rule enforces that the commit type must be one of the specified values, and the 'subject-case' rule ensures that the commit message subject is not in sentence case.
{
"rules": {
"type-enum": [2, "always", ["feat", "fix", "docs", "style", "refactor", "test", "chore"]],
"subject-case": [2, "never", ["sentence-case"]]
}
}
Integrating with Husky
commitlint can be integrated with Husky to automatically run commit message linting as a Git hook. This ensures that all commit messages are validated before they are committed.
{
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}