Skip to content

JS: Comment inside empty switch block moves into the discriminant #19578

Description

@leaysgur

Prettier v3.9.4
Playground link

--parser babel

Input:

// --- OK ---

if (a) {/*c*/}
while (a) {/*c*/}

// --- NG? ---

switch (a) {/*c*/}

Output:

// --- OK ---

if (a) {
  /*c*/
}
while (a) {
  /*c*/
}

// --- NG? ---

switch (a /*c*/) {
}

Expected output:

// --- OK ---

if (a) {
  /*c*/
}
while (a) {
  /*c*/
}

// --- NG? ---

switch (a) {
  /*c*/
}

Why?

Comment should stay inside of empty block.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions