Fix comments handling for for-statements that body is expression statements#9829
Fix comments handling for for-statements that body is expression statements#9829sosukesuzuki wants to merge 5 commits intoprettier:mainfrom
Conversation
|
Excluding Prettier pr-9829 --parser babelInput: for (const p of ['fullName', 'organ', 'position', 'rank'])
// @ts-expect-error
{form.setValue(`${prefix}.data.${p}`, response[p])}
for (const p of ['fullName', 'organ', 'position', 'rank'])
// @ts-expect-error
{}
for (const p of ['fullName', 'organ', 'position', 'rank'])
// @ts-expect-error
;Output: // @ts-expect-error
for (const p of ["fullName", "organ", "position", "rank"]) {
form.setValue(`${prefix}.data.${p}`, response[p]);
}
// @ts-expect-error
for (const p of ["fullName", "organ", "position", "rank"]) {
}
for (const p of ["fullName", "organ", "position", "rank"]);
// @ts-expect-error |
|
@fisker Yes, but it's inconsistent with Prettier 2.2.1 --parser babelInput: if (foo) {
// foo
}
// foo
for (;;) {}
switch (
bar
// foo
) {
}Output: if (foo) {
// foo
}
// foo
for (;;) {}
switch (
bar
// foo
) {
} |
|
Did you try not to special-case This Extending its effect to Prettier pr-9829 --parser babelInput: for (
a = 1;
// this condition is tricky:
a === b || a === c;
a++
) {
console.log()
}Output: // this condition is tricky:
for (a = 1; a === b || a === c; a++) {
console.log();
}Would be good to find a way to remove this function and find a better solution for #886 as the current one can change the order of comments: Prettier 2.2.1 --parser babelInput: for (/*a*/a
/*b*/
of b) breakOutput: /*b*/
for (/*a*/ a of b) break; |
|
These issues related to comments are really hard. Fixing individual edge cases we seem to be never sure we don't break other edge cases at the same time. |
Description
Fixes #9812
Checklist
changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨