Skip to content

missing line break after trailing comments of empty statement #18842

@Dunqing

Description

@Dunqing

Prettier 3.8.1
Playground link

--parser babel-ts

Input:
https://github.com/prettier/prettier/blob/812a4d0071270f61a7aa549d625b618be7e09d71/tests/format/js/comments/empty-statements.js#L1-L21

a; /* a */ // b
; /* c */

foo; // first
;// second
;// third

function x() {
} // first
; // second

Output:

a; /* a */ // b
/* c */
foo; // first
// second
// third
function x() {} // first
// second

Expected output:

a; /* a */ // b
/* c */

foo; // first
// second
// third

function x() {} // first
// second

Why?

Should be the same as a non-empty statement to maintain consistency

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JS

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions