-
Notifications
You must be signed in to change notification settings - Fork 944
Description
Expected Behavior
A breaking change can be denoted by either !
in the header (e.g., feat!: add advanced search filters
) or by including BREAKING CHANGE
in the footer (e.g., BREAKING CHANGE: old queries no longer work with the new API.
). I am proposing a lint that requires a BREAKING CHANGE
footer if !
appears in the header and a !
in the header if BREAKING CHANGE
appears in the footer. The idea is that it is all or nothing, so if one breaking change marker is present the other must be present too. I suggest this be called breaking-change-exclamation-mark
.
Current Behavior
There is currently no way to enforce this without writing a plugin.
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
Add a new rule that checks for:
!:
in the header,BREAKING[ -]CHANGE:
in the footer.
The lint passes if the checks are either both true
or both false
, but fails if the checks differ.
Context
This enforces a solution to three problems, illustrated using the examples in the Expected Behavior section.
- Using just
!
might not convey enough information. For example,feat!: add advanced search filters
. Why is this a breaking change? How do I know what broke unless the footer is present? - Using just
BREAKING CHANGE
might cause confusion. For example, if I use something likegit log --online
to quickly look at changes and I seefeat: add advanced search filters
, I have no idea that it is a breaking change. This is the same in the GitHub UI where it shows only the commit headers in most views (e.g., in pull requests). - This rule enforces the broadest tooling coverage since both means of denoting breaking changes are present in commit messages.
While this could be implemented as a plugin, I think it is both sensible and simple enough to be a feature included in commitlint itself, and users shouldn't need to add a dependency for such a straightforward check.