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(