Closed bartlomieju closed 3 days ago
I guess one work-around that could be done in Deno itself is to split into lines, trim them and then join. That will however make some comments formatting off. I'm gonna apply it for now to get rid of panics, but I think it'd be better to fix it in dprint itself.
dprint-plugin-typescript doesn't modify block comments. This is an issue somewhere else.
After discussion, we're going to improve dprint-plugin-typescript to handle de-indenting/indenting these kind of block comments. Initially we were thinking markup_fmt should de-indent itself, but it wouldn't be able to handle scenarios like:
<script>
const test = `
test
`;
console.log(test);
</script>
A few more examples of inputs that cause unstable format:
"{"; // This line cause panic
`
`;
`{
}`;
``;
@dsherret FYI I opened an issue with markup_fmt
and it appears these strings are passed in this way on purpose - https://github.com/g-plane/markup_fmt/issues/74#issuecomment-2456078219.
I'm beginning to think that dprint-plugin-typescript
could use a separate API like format_text_for_external_block
that would be aware of the indentation requirements, but I haven't figured it out yet.
Closing as this can now be solved with https://github.com/dprint/dprint-plugin-typescript/pull/689.
Describe the bug
dprint-plugin-typescript version: 0.93.0
Input Code
Expected Output
Actual Output
Then after using the "Actual output" as input to check for format stability we get:
and then again:
And it continues...
This is the root cause for https://github.com/denoland/deno/issues/26560