@@ -298,33 +298,26 @@ module.exports = {
298
298
] ;
299
299
} ,
300
300
301
- 'footer-notes-misplacement' : ( { raw } : { raw :any } ) => {
301
+ 'footer-notes-misplacement' : ( { body } : { body :any } ) => {
302
302
let offence = false ;
303
303
304
- let rawStr = convertAnyToString ( raw , "raw" ) . trim ( ) ;
305
- let lineBreakIndex = rawStr . indexOf ( '\n' ) ;
306
-
307
- if ( lineBreakIndex >= 0 ) {
308
- // Extracting bodyStr from rawStr rather than using body directly is a
309
- // workaround for https://github.com/conventional-changelog/commitlint/issues/3428
310
- let bodyStr = rawStr . substring ( lineBreakIndex ) . trim ( ) ;
304
+ if ( body !== null ) {
305
+ let bodyStr = convertAnyToString ( body , "body" ) ;
311
306
312
- if ( bodyStr !== '' ) {
313
- let seenBody = false ;
314
- let seenFooter = false ;
315
- let lines = bodyStr . split ( / \r ? \n / ) ;
316
- for ( let line of lines ) {
317
- if ( line . length === 0 ) {
318
- continue ;
319
- }
320
- seenBody = seenBody || ! isFooterNote ( line ) ;
321
- seenFooter = seenFooter || isFooterNote ( line ) ;
322
- if ( seenFooter && ! isFooterNote ( line ) ) {
323
- offence = true ;
324
- break ;
325
- }
326
-
307
+ let seenBody = false ;
308
+ let seenFooter = false ;
309
+ let lines = bodyStr . split ( / \r ? \n / ) ;
310
+ for ( let line of lines ) {
311
+ if ( line . length === 0 ) {
312
+ continue ;
313
+ }
314
+ seenBody = seenBody || ! isFooterNote ( line ) ;
315
+ seenFooter = seenFooter || isFooterNote ( line ) ;
316
+ if ( seenFooter && ! isFooterNote ( line ) ) {
317
+ offence = true ;
318
+ break ;
327
319
}
320
+
328
321
}
329
322
}
330
323
return [
@@ -333,46 +326,39 @@ module.exports = {
333
326
]
334
327
} ,
335
328
336
- 'footer-references-existence' : ( { raw } : { raw :any } ) => {
329
+ 'footer-references-existence' : ( { body } : { body :any } ) => {
337
330
let offence = false ;
338
331
339
- let rawStr = convertAnyToString ( raw , "raw" ) . trim ( ) ;
340
- let lineBreakIndex = rawStr . indexOf ( '\n' ) ;
332
+ if ( body !== null ) {
333
+ let bodyStr = convertAnyToString ( body , "body" ) ;
341
334
342
- if ( lineBreakIndex >= 0 ) {
343
- // Extracting bodyStr from rawStr rather than using body directly is a
344
- // workaround for https://github.com/conventional-changelog/commitlint/issues/3428
345
- let bodyStr = rawStr . substring ( lineBreakIndex ) . trim ( ) ;
346
-
347
- if ( bodyStr !== '' ) {
348
- let lines = bodyStr . split ( / \r ? \n / ) ;
349
- let bodyReferences = new Set ( ) ;
350
- let references = new Set ( ) ;
351
- for ( let line of lines ) {
352
- let matches = line . match ( / (?< = \[ ) ( [ 0 - 9 ] + ) (? = \] ) / g) ;
353
- if ( matches === null ) {
354
- continue ;
335
+ let lines = bodyStr . split ( / \r ? \n / ) ;
336
+ let bodyReferences = new Set ( ) ;
337
+ let references = new Set ( ) ;
338
+ for ( let line of lines ) {
339
+ let matches = line . match ( / (?< = \[ ) ( [ 0 - 9 ] + ) (? = \] ) / g) ;
340
+ if ( matches === null ) {
341
+ continue ;
342
+ }
343
+ for ( let match of matches ) {
344
+ if ( isFooterReference ( line ) ) {
345
+ references . add ( match ) ;
355
346
}
356
- for ( let match of matches ) {
357
- if ( isFooterReference ( line ) ) {
358
- references . add ( match ) ;
359
- }
360
- else {
361
- bodyReferences . add ( match ) ;
362
- }
347
+ else {
348
+ bodyReferences . add ( match ) ;
363
349
}
364
350
}
365
- for ( let ref of bodyReferences ) {
366
- if ( ! references . has ( ref ) ) {
367
- offence = true ;
368
- break ;
369
- }
351
+ }
352
+ for ( let ref of bodyReferences ) {
353
+ if ( ! references . has ( ref ) ) {
354
+ offence = true ;
355
+ break ;
370
356
}
371
- for ( let ref of references ) {
372
- if ( ! bodyReferences . has ( ref ) ) {
373
- offence = true ;
374
- break ;
375
- }
357
+ }
358
+ for ( let ref of references ) {
359
+ if ( ! bodyReferences . has ( ref ) ) {
360
+ offence = true ;
361
+ break ;
376
362
}
377
363
}
378
364
}
@@ -516,16 +502,11 @@ module.exports = {
516
502
] ;
517
503
} ,
518
504
519
- 'body-soft-max-line-length' : ( { raw } : { raw :any } ) => {
505
+ 'body-soft-max-line-length' : ( { body } : { body :any } ) => {
520
506
let offence = false ;
521
507
522
- let rawStr = convertAnyToString ( raw , "raw" ) . trim ( ) ;
523
- let lineBreakIndex = rawStr . indexOf ( '\n' ) ;
524
-
525
- if ( lineBreakIndex >= 0 ) {
526
- // Extracting bodyStr from rawStr rather than using body directly is a
527
- // workaround for https://github.com/conventional-changelog/commitlint/issues/3428
528
- let bodyStr = rawStr . substring ( lineBreakIndex ) ;
508
+ if ( body !== null ) {
509
+ let bodyStr = convertAnyToString ( body , "body" ) ;
529
510
530
511
bodyStr = removeAllCodeBlocks ( bodyStr ) . trim ( ) ;
531
512
0 commit comments