diff --git a/@commitlint/lint/src/lint.test.ts b/@commitlint/lint/src/lint.test.ts index 2b5d0ef40f1..0ceda795ec3 100644 --- a/@commitlint/lint/src/lint.test.ts +++ b/@commitlint/lint/src/lint.test.ts @@ -6,8 +6,11 @@ test('throws without params', async () => { }); test('throws with empty message', async () => { - const error = (lint as any)(''); - await expect(error).rejects.toThrow('Expected a raw commit'); + expect(await lint('')).toMatchObject({ + valid: true, + errors: [], + warnings: [] + }); }); test('positive on stub message and no rule', async () => { diff --git a/@commitlint/lint/src/lint.ts b/@commitlint/lint/src/lint.ts index 569c799abe3..badbebef635 100644 --- a/@commitlint/lint/src/lint.ts +++ b/@commitlint/lint/src/lint.ts @@ -28,8 +28,10 @@ export default async function lint( return LintOutcome.empty({message}); } - // Parse the commit message - const parsed = await parse(message, undefined, opts.parserOpts); + const parsed = + message === '' + ? {header: null, body: null, footer: null} + : await parse(message, undefined, opts.parserOpts); if ( parsed.header === null &&