Skip to content

Commit

Permalink
fix(commitlint): Parse breaking change headers correctly
Browse files Browse the repository at this point in the history
Before this change, using a header like "fix!: Something" caused the
following commitlint errors:

✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

It seems that the default header pattern does not recognize the
exclamation mark. To fix this, use the parser options from the
"conventional-changelog-conventionalcommits" template [1]. Using the
package as a parser preset would require that the NPM package is
installed, therfore copy the values from [2] instead.

[1]: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits
[2]: https://github.com/conventional-changelog/conventional-changelog/blob/bfe3bf1c49d4a125474b398b2d304749fd3b56c7/packages/conventional-changelog-conventionalcommits/parser-opts.js

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io>
  • Loading branch information
mnonnenmacher committed Jan 19, 2023
1 parent 813aa2b commit 1e69c34
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Commitlint configuration.
# See: https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
---
parserPreset:
parserOpts:
headerPattern: '^(\w*)(?:\((.*)\))?!?: (.*)$'
breakingHeaderPattern: '^(\w*)(?:\((.*)\))?!: (.*)$'
headerCorrespondence: ['type', 'scope', 'subject']
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE']
revertPattern: '/^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i'
revertCorrespondence: ['header', 'hash']
rules:
body-leading-blank:
- 2
Expand Down

0 comments on commit 1e69c34

Please sign in to comment.