File tree 2 files changed +25
-4
lines changed
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 () => {
5
5
await expect ( error ) . rejects . toThrow ( 'Expected a raw commit' ) ;
6
6
} ) ;
7
7
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
+ } ) ;
11
14
} ) ;
12
15
13
16
test ( '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(
36
36
}
37
37
38
38
// 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
+
40
58
const allRules : Map < string , BaseRule < never , RuleType > > = new Map (
41
59
Object . entries ( defaultRules )
42
60
) ;
You can’t perform that action at this time.
0 commit comments