forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add rule for
BREAKING CHANGE:
in subject
`BREAKING CHANGE:` is a footer thing Fixed conventional-changelog#3810
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import parse from '@commitlint/parse'; | ||
import {subjectBreaking} from './subject-breaking'; | ||
|
||
const messages = { | ||
empty: 'test: \nbody', | ||
filled: 'BREAKING CHANGE: this one', | ||
}; | ||
|
||
const parsed = { | ||
empty: parse(messages.empty), | ||
filled: parse(messages.filled), | ||
}; | ||
|
||
test('without subject should succeed', async () => { | ||
const [actual] = subjectBreaking(await parsed.empty); | ||
const expected = true; | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('subject fail with BREAKING CHANGE:', async () => { | ||
const [actual] = subjectBreaking(await parsed.filled); | ||
const expected = false; | ||
expect(actual).toEqual(expected); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {SyncRule} from '@commitlint/types'; | ||
|
||
export const subjectBreaking: SyncRule = (parsed) => { | ||
const result = parsed.subject?.startsWith('BREAKING CHANGE:'); | ||
|
||
return [!result, 'move BREAKING CHANGE: to footer']; | ||
}; |