prettier / prettier/prettier

missing line break after trailing comments of empty statement

Open
#18,842 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:comments lang:javascript
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/format/js/comments/empty-statements.js at the linked lines and reproduce the Babel TypeScript formatting case from the issue. Compare the current and expected outputs, then add or adjust the regression expectation so empty statements preserve the line break after trailing comments.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.