Skip to content

Improve comments inside for loop #10046

@fisker

Description

@fisker

Prettier pr-9857
Playground link

--parser babel

Input:

for(/*a*/;/*a*/;/*a*/);
for(/*a*/a;/*a*/;/*a*/);
for(/*a*/;a/*a*/;/*a*/);
for(/*a*/;/*a*/;a/*a*/);

Output:

/*a*/
/*a*/
/*a*/
for (;;);
for (/*a*/ a /*a*/ /*a*/; ; );
for (; /*a*/ a /*a*/ /*a*/; );
for (; ; /*a*/ /*a*/ a /*a*/);

Expected behavior:

Comments should stay at the original position.

Maybe we can use a solution like #9857

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