New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix comments handling for for-statements that body is expression statements #9829
base: main
Are you sure you want to change the base?
Conversation
Excluding Prettier pr-9829 --parser babel Input: 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 babel Input: 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 babel Input: 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 babel Input: for (/*a*/a
/*b*/
of b) break Output: /*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.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨