conventional-changelog / conventional-changelog/commitlint
How to use parser headerPattern
- Dominant language
- TypeScript
- Stars
- 18.7k
- Forks
- 970
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 49
Description
The task is to use commitlint to prevent commits from being commited. I use husky as well
when I test it and run
` echo "bla bla bla" | npx commitlint`
It doesn't catch anything and shows no errors found
```
⧗ input: bla bla bla
✔ found 0 problems, 0 warnings
```
Please, help, why it ignores `parserOpts.headerPattern` ?
Also some other notice:
I need at least one rule, otherwise `commitlint` doesn't want to run
Do I need to add `headerCorrespondence` to make it work or I can have `headerPattern` only?
Can I customize report message in case if I `headerPattern` is not matched?
commitlint.config.js
```js
module.exports = {
rules: {
'header-min-length': [2, 'always', 20],
},
parserPreset: {
parserOpts: {
headerPattern: /^(feat|fix|perf|test|BREAKING CHANGE):.*\[REF-(\d{3,}|N\\A)\] \S+ \S+ \S+ \S+ \S+/,
headerCorrespondence: ['type', 'scope', 'subject']
}
}
};
```
husky in package.json
```js
"husky": {
"hooks": {
"pre-push": "npm test",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
```
I installed the next
```
"@commitlint/cli": "^7.5.2",
"@commitlint/parse": "^7.5.0",
```
Contributor guide
Research direction
Start by reproducing the reported command with the provided commitlint.config.js and package versions, then inspect how parserOpts.headerPattern and headerCorrespondence are consumed. Check the commitlint CLI entry point and related parser or rule tests if available. Done means establishing whether the unmatched header should produce a lint result and documenting the required configuration or behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, javascript, node.js
- Domain
- cli, developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100