Skip to content

Commit a3d5ab0

Browse files
committedNov 12, 2020
fix(lint): 🐛 detect BREAKING CHANGE in description. Fixes #76
1 parent 8138c84 commit a3d5ab0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed
 

‎__tests__/conventional-commits.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ test("type with scope commit msg", () => {
2121
expect(cc.formatCommit("feat(cli): testing")).toBe("feat(cli): ✨ testing")
2222
})
2323

24+
test("breaking changes", () => {
25+
const cc = new ConventionalCommits(new Devmoji(new Config()))
26+
expect(cc.formatCommit("feat(cli)!: important")).toBe(
27+
"feat(cli)!: 💥 ✨ important"
28+
)
29+
})
30+
31+
test("breaking changes multiline", () => {
32+
const cc = new ConventionalCommits(new Devmoji(new Config()))
33+
expect(
34+
cc.formatCommit("feat(cli): important\nBREAKING CHANGE: foo bar")
35+
).toBe("feat(cli): 💥 ✨ important\nBREAKING CHANGE: foo bar")
36+
})
37+
2438
test("type with scope release commit msg", () => {
2539
const cc = new ConventionalCommits(new Devmoji(new Config()))
2640
expect(cc.formatCommit("chore(release): testing")).toBe(
@@ -36,7 +50,7 @@ test("type with scope release commit msg and devmoji", () => {
3650
)
3751
})
3852

39-
test("invalid commit msg ", () => {
53+
test("invalid commit msg", () => {
4054
const cc = new ConventionalCommits(new Devmoji(new Config()))
4155
expect(cc.formatCommit("invalid commit")).toBe("invalid commit")
4256
})
@@ -66,7 +80,7 @@ chore(release): 🚀 deploy
6680
eat(cli): 🚨 testing`)
6781
})
6882

69-
test("should ", () => {
83+
test("should", () => {
7084
const text =
7185
"* 8f16492 - feat(cli): ✨ added cli for working with devmoji 🚀 (19 hours ago) <Folke Lemaitre>"
7286
const cc = new ConventionalCommits(new Devmoji(new Config()))
@@ -76,7 +90,7 @@ test("should ", () => {
7690
)
7791
})
7892

79-
test("multi log & commit ", () => {
93+
test("multi log & commit", () => {
8094
const tests: [string, string][] = [
8195
["feat(foo): testing", "feat(foo): :sparkles: testing"],
8296
["foo(security): testing", "foo(security): :security: testing"],

‎src/conventional-commits.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class ConventionalCommits {
5050

5151
format(text: string, firstOnly = false, color = false) {
5252
text = this.devmoji.devmojify(text)
53+
const breakingDesc = /^\s*BREAKING CHANGE/mu.test(text)
5354
return this.devmoji.emojify(
5455
text.replace(
5556
this.regex,
@@ -67,7 +68,7 @@ export class ConventionalCommits {
6768
type,
6869
scope,
6970
other,
70-
breaking ? true : false
71+
breaking || breakingDesc ? true : false
7172
)
7273
if (!emoji.length) return match
7374
let ret = type

0 commit comments

Comments
 (0)
Please sign in to comment.