Skip to content

Multiple comments on top of if statement get separated #3105

@timm-gs

Description

@timm-gs

When adding explanatory comments after Istanbul comments, prettier moves them around into a basically unformatted state.

Prettier 1.7.4
Playground link

Input:

  const x = 0;
  
  /* istanbul ignore if */ // debug case currently not triggered
  if (true) {
    x;
  }

Output:

const x = 0; // debug case currently not triggered

/* istanbul ignore if */ if (true) {
  x;
}

Expected behavior:

I would expect the following output to remain unchanged with regards to the comments:

  const x = 0;
  
  /* istanbul ignore if */ // debug case currently not triggered
  if (true) {
    x;
  }

I would expect the comments to stick to the if, where they must be for Istanbul to pick them up

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