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
You can move the line comment above the block comment as a workaround.
Prettier 1.7.4
Playground link
Input:
const x = 0;
// debug case currently not triggered
/* istanbul ignore if */
if (true) {
x;
}
Output:
const x = 0;
// debug case currently not triggered
/* istanbul ignore if */
if (true) {
x;
}
Most helpful comment
You can move the line comment above the block comment as a workaround.
Prettier 1.7.4
Playground link
Input:
Output: