From daae0148f28ccd60ba604de42f30d2270dfa7545 Mon Sep 17 00:00:00 2001 From: dangreen Date: Wed, 19 Jan 2022 15:24:03 +0700 Subject: [PATCH] fix: commit body should be empty by default --- @commitlint/cz-commitlint/src/SectionBody.test.ts | 8 ++++++++ @commitlint/cz-commitlint/src/SectionBody.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/@commitlint/cz-commitlint/src/SectionBody.test.ts b/@commitlint/cz-commitlint/src/SectionBody.test.ts index 161b548989..26f3750952 100644 --- a/@commitlint/cz-commitlint/src/SectionBody.test.ts +++ b/@commitlint/cz-commitlint/src/SectionBody.test.ts @@ -83,4 +83,12 @@ describe('combineCommitMessage', () => { }); expect(commitMessage).toBe('This is issue body message.'); }); + + test('should return empty message when body is empty', () => { + setRules({}); + const commitMessage = combineCommitMessage({ + body: '', + }); + expect(commitMessage).toBe(''); + }); }); diff --git a/@commitlint/cz-commitlint/src/SectionBody.ts b/@commitlint/cz-commitlint/src/SectionBody.ts index 1ea38bf6c0..d5f00a3e18 100644 --- a/@commitlint/cz-commitlint/src/SectionBody.ts +++ b/@commitlint/cz-commitlint/src/SectionBody.ts @@ -19,7 +19,7 @@ export function combineCommitMessage(answers: Answers): string { const leadingBlankFn = getLeadingBlankFn(getRule('body', 'leading-blank')); const {body, breakingBody, issuesBody} = answers; - const commitBody = body || breakingBody || issuesBody || '-'; + const commitBody = body || breakingBody || issuesBody || ''; if (commitBody) { return leadingBlankFn(