Skip to content

Commit a3b6915

Browse files
feat(rules): breaking-change-exclamation-mark pull request changes
Addresses review feedback from @JounQin about pull request #4548. - Use `breakingHeaderPattern` to search for the exclamation mark in the header. - Correct the regular expression to require that BREAKING CHANGE in the footer be anchored at the beginning of a line. - Updated the `RulesConfig` type.
1 parent c200f4a commit a3b6915

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

@commitlint/rules/src/breaking-change-exclamation-mark.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export const breakingChangeExclamationMark: SyncRule = (
1616
return [true];
1717
}
1818

19-
const hasExclamationMark = !!header && /!:/.test(header);
20-
const hasBreakingChange = !!footer && /BREAKING[ -]CHANGE:/.test(footer);
19+
const hasExclamationMark =
20+
!!header && /^(\w*)(?:\((.*)\))?!: (.*)$/.test(header);
21+
const hasBreakingChange = !!footer && /^BREAKING[ -]CHANGE:/m.test(footer);
2122

2223
const negated = when === "never";
2324
const check = hasExclamationMark === hasBreakingChange;

@commitlint/types/src/rules.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export type RulesConfig<V = RuleConfigQuality.User> = {
9797
"body-max-length": LengthRuleConfig<V>;
9898
"body-max-line-length": LengthRuleConfig<V>;
9999
"body-min-length": LengthRuleConfig<V>;
100+
"breaking-change-exclamation-mark": CaseRuleConfig<V>;
100101
"footer-empty": RuleConfig<V>;
101102
"footer-leading-blank": RuleConfig<V>;
102103
"footer-max-length": LengthRuleConfig<V>;

0 commit comments

Comments
 (0)