File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,12 @@ test('throws without params', async () => {
55 await expect ( error ) . rejects . toThrow ( 'Expected a raw commit' ) ;
66} ) ;
77
8- test ( 'throws with empty message' , async ( ) => {
9- const error = ( lint as any ) ( '' ) ;
10- await expect ( error ) . rejects . toThrow ( 'Expected a raw commit' ) ;
8+ test ( 'positive on empty message' , async ( ) => {
9+ expect ( await lint ( '' ) ) . toMatchObject ( {
10+ valid : true ,
11+ errors : [ ] ,
12+ warnings : [ ]
13+ } ) ;
1114} ) ;
1215
1316test ( 'positive on stub message and no rule' , async ( ) => {
Original file line number Diff line number Diff line change @@ -36,7 +36,25 @@ export default async function lint(
3636 }
3737
3838 // Parse the commit message
39- const parsed = await parse ( message , undefined , opts . parserOpts ) ;
39+ const parsed =
40+ message === ''
41+ ? { header : null , body : null , footer : null }
42+ : await parse ( message , undefined , opts . parserOpts ) ;
43+
44+ if (
45+ parsed . header === null &&
46+ parsed . body === null &&
47+ parsed . footer === null
48+ ) {
49+ // Commit is empty, skip
50+ return {
51+ valid : true ,
52+ errors : [ ] ,
53+ warnings : [ ] ,
54+ input : message
55+ } ;
56+ }
57+
4058 const allRules : Map < string , BaseRule < never , RuleType > > = new Map (
4159 Object . entries ( defaultRules )
4260 ) ;
You can’t perform that action at this time.
0 commit comments