44 addLeadingComment,
55 addDanglingComment,
66 addTrailingComment,
7- getNextNonSpaceNonCommentCharacterIndex,
8- isNextLineEmpty,
97 skipNewline,
10- isPreviousLineEmpty,
118 hasNewline,
12- hasNewlineInRange
9+ hasNewlineInRange,
1310} = require ( "prettier" ) . util ;
1411const {
1512 concat,
@@ -18,9 +15,14 @@ const {
1815 hardline,
1916 cursor,
2017 lineSuffix,
21- breakParent
18+ breakParent,
2219} = require ( "prettier" ) . doc . builders ;
23- const { isLookupNode } = require ( "./util" ) ;
20+ const {
21+ getNextNonSpaceNonCommentCharacterIndex,
22+ isNextLineEmpty,
23+ isPreviousLineEmpty,
24+ isLookupNode,
25+ } = require ( "./util" ) ;
2426
2527/*
2628Comment functions are meant to inspect various edge cases using given comment nodes,
@@ -461,7 +463,7 @@ function handleClassComments(enclosingNode, followingNode, comment) {
461463 }
462464 } else {
463465 if (
464- enclosingNode . extends . some ( extendsNode => {
466+ enclosingNode . extends . some ( ( extendsNode ) => {
465467 if ( followingNode && followingNode === extendsNode ) {
466468 addDanglingComment ( followingNode , comment ) ;
467469 return true ;
@@ -477,7 +479,7 @@ function handleClassComments(enclosingNode, followingNode, comment) {
477479 // them as dangling comments and handle them in the printer
478480 if ( followingNode && enclosingNode . implements ) {
479481 if (
480- enclosingNode . implements . some ( implementsNode => {
482+ enclosingNode . implements . some ( ( implementsNode ) => {
481483 if ( followingNode && followingNode === implementsNode ) {
482484 addDanglingComment ( followingNode , comment ) ;
483485 return true ;
@@ -830,7 +832,7 @@ function printDanglingComments(path, options, sameIndent, filter) {
830832 return "" ;
831833 }
832834
833- path . each ( commentPath => {
835+ path . each ( ( commentPath ) => {
834836 const comment = commentPath . getValue ( ) ;
835837 if (
836838 comment &&
@@ -853,18 +855,18 @@ function printDanglingComments(path, options, sameIndent, filter) {
853855}
854856
855857function hasLeadingComment ( node ) {
856- return node . comments && node . comments . some ( comment => comment . leading ) ;
858+ return node . comments && node . comments . some ( ( comment ) => comment . leading ) ;
857859}
858860
859861function hasTrailingComment ( node ) {
860- return node . comments && node . comments . some ( comment => comment . trailing ) ;
862+ return node . comments && node . comments . some ( ( comment ) => comment . trailing ) ;
861863}
862864
863865function hasLeadingOwnLineComment ( text , node , options ) {
864866 return (
865867 node . comments &&
866868 node . comments . some (
867- comment => comment . leading && hasNewline ( text , options . locEnd ( comment ) )
869+ ( comment ) => comment . leading && hasNewline ( text , options . locEnd ( comment ) )
868870 )
869871 ) ;
870872}
@@ -897,10 +899,10 @@ function getCommentChildNodes(node) {
897899 return [ ] ;
898900 }
899901
900- const getChildNodes = node =>
902+ const getChildNodes = ( node ) =>
901903 Object . keys ( node )
902904 . filter (
903- n =>
905+ ( n ) =>
904906 n !== "kind" &&
905907 n !== "loc" &&
906908 n !== "errors" &&
@@ -911,7 +913,7 @@ function getCommentChildNodes(node) {
911913 n !== "precedingNode" &&
912914 n !== "followingNode"
913915 )
914- . map ( n => node [ n ] ) ;
916+ . map ( ( n ) => node [ n ] ) ;
915917
916918 return getChildNodes ( node ) ;
917919}
@@ -948,7 +950,9 @@ function printLeadingComment(commentPath, print, options) {
948950 if ( isBlock ) {
949951 return concat ( [
950952 contents ,
951- hasNewline ( options . originalText , options . locEnd ( comment ) ) ? hardline : " "
953+ hasNewline ( options . originalText , options . locEnd ( comment ) )
954+ ? hardline
955+ : " " ,
952956 ] ) ;
953957 }
954958
@@ -966,7 +970,7 @@ function printTrailingComment(commentPath, print, options) {
966970
967971 if (
968972 hasNewline ( options . originalText , options . locStart ( comment ) , {
969- backwards : true
973+ backwards : true ,
970974 } )
971975 ) {
972976 // This allows comments at the end of nested structures:
@@ -997,7 +1001,7 @@ function printTrailingComment(commentPath, print, options) {
9971001
9981002 return concat ( [
9991003 lineSuffix ( concat ( [ " " , contents ] ) ) ,
1000- ! isBlock ? breakParent : ""
1004+ ! isBlock ? breakParent : "" ,
10011005 ] ) ;
10021006}
10031007
@@ -1013,7 +1017,7 @@ function printAllComments(path, print, options, needsSemi) {
10131017 const leadingParts = [ ] ;
10141018 const trailingParts = [ needsSemi ? ";" : "" , printed ] ;
10151019
1016- path . each ( commentPath => {
1020+ path . each ( ( commentPath ) => {
10171021 const comment = commentPath . getValue ( ) ;
10181022 const { leading, trailing } = comment ;
10191023
@@ -1052,5 +1056,5 @@ module.exports = {
10521056 hasTrailingComment,
10531057 hasLeadingOwnLineComment,
10541058 printComments,
1055- printAllComments
1059+ printAllComments,
10561060} ;
0 commit comments