File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,19 +22,18 @@ export function printComments(
2222 options : ParserOptions < AstNode >
2323) : Doc [ ] {
2424 if ( node . comments === undefined ) return [ ] ;
25+ const lastPrintableIndex = node . comments . findLastIndex ( isPrintable ) ;
2526 return joinExisting (
2627 line ,
27- path . map ( ( { node : comment } , index , comments : Comment [ ] ) => {
28+ path . map ( ( { node : comment } , index ) => {
2829 if ( ! isPrintable ( comment ) ) {
2930 return '' ;
3031 }
3132 comment . printed = true ;
32- const isLast =
33- index === comments . length - 1 ||
34- comments . slice ( index + 1 ) . findIndex ( isPrintable ) === - 1 ;
3533 return [
3634 printComment ( path ) ,
37- ! isLast && util . isNextLineEmpty ( options . originalText , locEnd ( comment ) )
35+ index !== lastPrintableIndex &&
36+ util . isNextLineEmpty ( options . originalText , locEnd ( comment ) )
3837 ? hardline
3938 : ''
4039 ] ;
You can’t perform that action at this time.
0 commit comments