@@ -1297,25 +1297,26 @@ function printClass(path, options, print) {
12971297 }
12981298 }
12991299
1300+ const hasEmptyClassBody =
1301+ node . body && node . body . length === 0 && ! hasDanglingComments ( node ) ;
1302+
13001303 const printedDeclaration = group ( [
13011304 group ( declaration ) ,
1302- shouldPrintHardlineForOpenBrace ( options )
1305+ shouldPrintHardlineForOpenBrace ( options ) && ! hasEmptyClassBody
13031306 ? isAnonymousClass
13041307 ? line
13051308 : hardline
13061309 : " " ,
13071310 ] ) ;
13081311
1309- const hasEmptyClassBody =
1310- node . body && node . body . length === 0 && ! hasDanglingComments ( node ) ;
13111312 const printedBody = [
13121313 "{" ,
13131314 indent ( [
13141315 hasEmptyClassBody ? "" : hardline ,
13151316 printStatements ( path , options , print , "body" ) ,
13161317 ] ) ,
13171318 printDanglingComments ( path , options , true ) ,
1318- isAnonymousClass && hasEmptyClassBody ? softline : hardline ,
1319+ hasEmptyClassBody ? "" : hardline ,
13191320 "}" ,
13201321 ] ;
13211322
@@ -1383,14 +1384,14 @@ function printFunction(path, options, print) {
13831384 return [ ...declAttrs , printedDeclaration ] ;
13841385 }
13851386
1386- const isClosure = node . kind === "closure" ;
13871387 const printedBody = [
13881388 "{" ,
13891389 indent ( [ hasEmptyBody ( path ) ? "" : hardline , print ( "body" ) ] ) ,
1390- isClosure && hasEmptyBody ( path ) ? "" : hardline ,
1390+ hasEmptyBody ( path ) ? "" : hardline ,
13911391 "}" ,
13921392 ] ;
13931393
1394+ const isClosure = node . kind === "closure" ;
13941395 if ( isClosure ) {
13951396 return [ ...declAttrs , printedDeclaration , " " , printedBody ] ;
13961397 }
@@ -1399,7 +1400,9 @@ function printFunction(path, options, print) {
13991400 return [
14001401 ...declAttrs ,
14011402 printedDeclaration ,
1402- shouldPrintHardlineForOpenBrace ( options ) ? hardline : " " ,
1403+ shouldPrintHardlineForOpenBrace ( options ) && ! hasEmptyBody ( path )
1404+ ? hardline
1405+ : " " ,
14031406 printedBody ,
14041407 ] ;
14051408 }
@@ -1415,7 +1418,9 @@ function printFunction(path, options, print) {
14151418 conditionalGroup ( [
14161419 [
14171420 printedDeclaration ,
1418- shouldPrintHardlineForOpenBrace ( options ) ? hardline : " " ,
1421+ shouldPrintHardlineForOpenBrace ( options ) && ! hasEmptyBody ( path )
1422+ ? hardline
1423+ : " " ,
14191424 printedBody ,
14201425 ] ,
14211426 [ printedDeclaration , " " , printedBody ] ,
0 commit comments