This is the smallest example I could create
before:
$colors: (
light: #fff,
);
//
//
after:
$colors: (
light: #fff
);
li
);
Empty comments are removed and replaced with garbage pulled from elsewhere in the file.
I first saw this happening with a much larger file with a much longer defintion of $colors followed by a block of comments (// not /* */) which had multiple empty comment lines for paragraph spacing. The formatter a) replaced a couple empty comment lines with a pair of characters from a different line (as above) and b) removed others leaving an empty line. After removing the erroring characters, subsequent format would then remove those empty lines (also undesired behavior) clumping the comment paragraphs into a single block.
I've looked for a setting to disable formatting of any comments but I couldn't find any.
I'm happy to move this issue to https://github.com/prettier/prettier if that's a better place.
This doesn't seem to be the case when using latest prettier. We would need to update it in this extension.
Related - ignore rules are not obeyed.
Before formatting:
/* prettier-ignore-start */
$mq-footer_row3: em(700); // [1]
$mq-promoBrandsList-medium: em(550); // [2]
$mq-promoBrandsList-large: em(930); // [3]
$mq-promo4coloumn: em(450); // [4]
/* prettier-ignore-end */
After formatting:
/* prettier-ignore-start */
$mq-footer_row3: em(700); // [1]
$mq-promoBrandsList-medium: em(550); // [2]
$mq-promoBrandsList-large: em(930); // [3]
$mq-promo4coloumn: em(450); // [4]
/* prettier-ignore-end */
Code blocks in Javascript are ignored:
// prettier-ignore-start
export const Basic = [
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S
]
// prettier-ignore-end
// prettier-ignore-start
export const Basic = [
S,
S,
S,
...
]
// prettier-ignore-end
Can confirm the example I posted last year indeed works fine now, and I've dug up what i think was the "much larger file" I referenced, and there's no breaking changes in the formatter.
I would still note that empty lines in an array definition are removed (arguable functionality), and in testing that I stumbled across another problem:
$colors: (
surface: (),
// comment
success: (),
);
$colors: (
surface: (),
// comment success: (),
);
Note this doesn't occur for this slightly changed version however the output still isn't ideal
$colors: (
surface: 5px,
// comment
success: (),
);
$colors: (
surface: 5px,
// comment
success: (),
);
This issue appears to be resolved as such I am closing it. If you are still having problems please feel free to reopen.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Related - ignore rules are not obeyed.
Before formatting:
After formatting: