Skip to content

feat: rule to require both ! and BREAKING CHANGE #4547

@adamchristiansen

Description

@adamchristiansen

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.

  1. 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?
  2. Using just BREAKING CHANGE might cause confusion. For example, if I use something like git log --online to quickly look at changes and I see feat: 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).
  3. 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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions