@@ -337,33 +337,26 @@ module.exports = {
337
337
] ;
338
338
} ,
339
339
340
- 'footer-notes-misplacement' : ( { raw } : { raw :any } ) => {
340
+ 'footer-notes-misplacement' : ( { body } : { body :any } ) => {
341
341
let offence = false ;
342
342
343
- let rawStr = convertAnyToString ( raw , "raw" ) . trim ( ) ;
344
- let lineBreakIndex = rawStr . indexOf ( '\n' ) ;
345
-
346
- if ( lineBreakIndex >= 0 ) {
347
- // Extracting bodyStr from rawStr rather than using body directly is a
348
- // workaround for https://github.com/conventional-changelog/commitlint/issues/3428
349
- let bodyStr = rawStr . substring ( lineBreakIndex ) . trim ( ) ;
343
+ if ( body !== null ) {
344
+ let bodyStr = convertAnyToString ( body , "body" ) ;
350
345
351
- if ( bodyStr !== '' ) {
352
- let seenBody = false ;
353
- let seenFooter = false ;
354
- let lines = bodyStr . split ( / \r ? \n / ) ;
355
- for ( let line of lines ) {
356
- if ( line . length === 0 ) {
357
- continue ;
358
- }
359
- seenBody = seenBody || ! isFooterNote ( line ) ;
360
- seenFooter = seenFooter || isFooterNote ( line ) ;
361
- if ( seenFooter && ! isFooterNote ( line ) ) {
362
- offence = true ;
363
- break ;
364
- }
365
-
346
+ let seenBody = false ;
347
+ let seenFooter = false ;
348
+ let lines = bodyStr . split ( / \r ? \n / ) ;
349
+ for ( let line of lines ) {
350
+ if ( line . length === 0 ) {
351
+ continue ;
352
+ }
353
+ seenBody = seenBody || ! isFooterNote ( line ) ;
354
+ seenFooter = seenFooter || isFooterNote ( line ) ;
355
+ if ( seenFooter && ! isFooterNote ( line ) ) {
356
+ offence = true ;
357
+ break ;
366
358
}
359
+
367
360
}
368
361
}
369
362
return [
@@ -373,46 +366,39 @@ module.exports = {
373
366
]
374
367
} ,
375
368
376
- 'footer-references-existence' : ( { raw } : { raw :any } ) => {
369
+ 'footer-references-existence' : ( { body } : { body :any } ) => {
377
370
let offence = false ;
378
371
379
- let rawStr = convertAnyToString ( raw , "raw" ) . trim ( ) ;
380
- let lineBreakIndex = rawStr . indexOf ( '\n' ) ;
372
+ if ( body !== null ) {
373
+ let bodyStr = convertAnyToString ( body , "body" ) ;
381
374
382
- if ( lineBreakIndex >= 0 ) {
383
- // Extracting bodyStr from rawStr rather than using body directly is a
384
- // workaround for https://github.com/conventional-changelog/commitlint/issues/3428
385
- let bodyStr = rawStr . substring ( lineBreakIndex ) . trim ( ) ;
386
-
387
- if ( bodyStr !== '' ) {
388
- let lines = bodyStr . split ( / \r ? \n / ) ;
389
- let bodyReferences = new Set ( ) ;
390
- let references = new Set ( ) ;
391
- for ( let line of lines ) {
392
- let matches = line . match ( / (?< = \[ ) ( [ 0 - 9 ] + ) (? = \] ) / g) ;
393
- if ( matches === null ) {
394
- continue ;
375
+ let lines = bodyStr . split ( / \r ? \n / ) ;
376
+ let bodyReferences = new Set ( ) ;
377
+ let references = new Set ( ) ;
378
+ for ( let line of lines ) {
379
+ let matches = line . match ( / (?< = \[ ) ( [ 0 - 9 ] + ) (? = \] ) / g) ;
380
+ if ( matches === null ) {
381
+ continue ;
382
+ }
383
+ for ( let match of matches ) {
384
+ if ( isFooterReference ( line ) ) {
385
+ references . add ( match ) ;
395
386
}
396
- for ( let match of matches ) {
397
- if ( isFooterReference ( line ) ) {
398
- references . add ( match ) ;
399
- }
400
- else {
401
- bodyReferences . add ( match ) ;
402
- }
387
+ else {
388
+ bodyReferences . add ( match ) ;
403
389
}
404
390
}
405
- for ( let ref of bodyReferences ) {
406
- if ( ! references . has ( ref ) ) {
407
- offence = true ;
408
- break ;
409
- }
391
+ }
392
+ for ( let ref of bodyReferences ) {
393
+ if ( ! references . has ( ref ) ) {
394
+ offence = true ;
395
+ break ;
410
396
}
411
- for ( let ref of references ) {
412
- if ( ! bodyReferences . has ( ref ) ) {
413
- offence = true ;
414
- break ;
415
- }
397
+ }
398
+ for ( let ref of references ) {
399
+ if ( ! bodyReferences . has ( ref ) ) {
400
+ offence = true ;
401
+ break ;
416
402
}
417
403
}
418
404
}
@@ -565,16 +551,11 @@ module.exports = {
565
551
] ;
566
552
} ,
567
553
568
- 'body-soft-max-line-length' : ( { raw } : { raw :any } ) => {
554
+ 'body-soft-max-line-length' : ( { body } : { body :any } ) => {
569
555
let offence = false ;
570
556
571
- let rawStr = convertAnyToString ( raw , "raw" ) . trim ( ) ;
572
- let lineBreakIndex = rawStr . indexOf ( '\n' ) ;
573
-
574
- if ( lineBreakIndex >= 0 ) {
575
- // Extracting bodyStr from rawStr rather than using body directly is a
576
- // workaround for https://github.com/conventional-changelog/commitlint/issues/3428
577
- let bodyStr = rawStr . substring ( lineBreakIndex ) ;
557
+ if ( body !== null ) {
558
+ let bodyStr = convertAnyToString ( body , "body" ) ;
578
559
579
560
bodyStr = removeAllCodeBlocks ( bodyStr ) . trim ( ) ;
580
561
0 commit comments