You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect that for any code base the command deno fmt && deno fmt --check succeeds. However, this is not the case, as the following example illustrates.
$ cat file.ts # badly formatted file
const buttonCount = 10;functionfoo() {
for (let i = 0; i < buttonCount; i++) { range.text(i.toString(), (ctx) => ctx.reply(`${i} selected`));
}
}
$ deno fmt --check file.ts
from /tmp/file.ts:
4 | - for (let i = 0; i < buttonCount; i++) { range.text(i.toString(), (ctx) => ctx.reply(`${i} selected`));
4 | + for (let i = 0; i < buttonCount; i++) {
5 | + range.text(i.toString(), (ctx) =>
6 | + ctx.reply(`${i} selected`));
7 | -
8 | -
9 | +
error: Found 1 not formatted file in 1 file
$ deno fmt file.ts
/tmp/file.ts
Checked 1 file
$ deno fmt file.ts --check
from /tmp/fie.ts:
5 | - range.text(i.toString(), (ctx) =>
6 | - ctx.reply(`${i} selected`));
5 | + range.text(i.toString(), (ctx) => ctx.reply(`${i} selected`));
error: Found 1 not formatted file in 1 file
$ deno fmt file.ts
/tmp/file.ts
Checked 1 file
$ deno fmt file.ts --check
Checked 1 file
The text was updated successfully, but these errors were encountered:
dsherret
changed the title
deno fmt is not idempotent
deno fmt double format issue with single line for stmt with call expr with arrow function argument
Nov 8, 2021
When troubleshooting the following using the order of command, I do not receive the same errors that you are receiving. Seems to be working fine for me. I am running Windows 11 and executing via Powershell running the trunk version as it currently stands today. You are saying that you entered the commands in this order and had to run deno fmt twice?
These commands work now because #14314 changed deno fmt to retry until the formatting is stable. The underlying issue remains unresolved and can still be observed when formatting the file in an editor with deno lsp.
@0f-0b does that actually mean that deno fmt does one useless pass over all files? In most cases, this would mean that it makes twice as many passes as needed. Isn't that a fairly large performance overhead?
deno fmt does not exhibit this behaviour anymore because we format until the result is stable. Upstream bug is tracked in dprint/dprint-plugin-typescript#670
I would expect that for any code base the command
deno fmt && deno fmt --check
succeeds. However, this is not the case, as the following example illustrates.The text was updated successfully, but these errors were encountered: