markup_fmt icon indicating copy to clipboard operation
markup_fmt copied to clipboard

fmt(svelte): formatter error on dynamic style in svelte

Open MohammadSu1 opened this issue 1 year ago • 2 comments

Version Deno 2.1.1

<script lang="ts">
  const { color }: { color: string | null } = $props();
</script>

<div
  style="background-color: {color || 'blueviolet'};"
>
</div>
deno fmt --unstable-component
Error formatting: C:\temp\deno-init\test.svelte
   syntax error at line 6, col 28: expect token `<ident>`, but found `{`
Checked 4 files

Originally reported in https://github.com/denoland/deno/issues/26999

MohammadSu1 avatar Nov 24 '24 07:11 MohammadSu1

This is a known issue, but hard to fix at this moment.

g-plane avatar Nov 25 '24 02:11 g-plane

It's not quite idiomatic Svelte. It could be better written as:

<div style:background-color={color || 'blueviolet'}></div>

notramo avatar Dec 05 '24 18:12 notramo