Skip to content

Improve comment handling in SwitchStatement #19582

Description

@fisker

Prettier v3.9.4
Playground link

--parser babel

Input:

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

Output:

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

Expected output:

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

Why?

It's not easy to fix, since there is no node for the "body" in SwitchStatement to attach leading comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions