Repository: deno
Issue: fmt - Produce invalid Svelte code (or panik) when there's a switch case in Svelte's HTML part
Labels: bug,deno fmt,triage required 👀

`deno fmt --unstable-component` produce invalid Svelte code (or panik) when there's a switch case in Svelte's HTML part

<details>
<summary>Reproduction # 1 (Produce invalid Svelte code)</summary>

Input:

```svelte
<div
class="placeholder {arr.some((ele) => {
	switch (ele) {
		case 1:
			return true
		case 2:
			return true
		case 3:
			return true
	}
})
	? ''
	: 'hidden'}"
>
</div>
```

Output:

```svelte
<div
  class="placeholder {arr.some((ele) => { switch (ele) { case 1: return true case 2: return true case 3: return true } }) ? '' : 'hidden'}"
>
</div>
```

Deno fmt removes all new lines but doesn't add any semicolons.

(There's no deno.json so I'm pretty sure this is deno fmt's default settings)

</details>

<details>
<summary>Reproduction # 2 (Deno fmt panik)</summary>

Input:

```svelte
<div
class=" {arr.some((ele) => {
	switch (ele) {
		case 1:
			return true
		case 2:
			return true
		case 3:
			return true
	}
})
	? ''
	: 'hidden'}"
>
</div>

```

In this case, there's a trailing whitespace at the beginning and deno panik

Logs:

```
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 2.0.2
Args: ["deno", "fmt", "--unstable-component", "--watch"]

thread 'tokio-runtime-worker' panicked at cli/tools/fmt.rs:778:13:
Formatting succeeded initially, but failed when ensuring a stable format. This indicates a bug in the formatter where the text it produces is not syntactically correct. As a temporary workaround you can ignore this file (/home/lts20050703/git/test/test.svelte).

Expected ',', got '.' at file:///home/lts20050703/git/test/test.svelte.tsx:2:13

        <>{arr.some((ele) => { switch (ele) { case 1: return true case 2: return t...
              ~
stack backtrace:
   0:     0x6449e9552a75 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b9dad2a88e955ff
   1:     0x6449e95843db - core::fmt::write::h4b5a1270214bc4a7
   2:     0x6449e954cd2f - std::io::Write::write_fmt::hd04af345a50c312d
   3:     0x6449e9554291 - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed
   4:     0x6449e9553f6c - std::panicking::default_hook::h3cacb9c27561ad33
   5:     0x6449e9ba5271 - deno::setup_panic_hook::{{closure}}::hd1640e60cae751ab
   6:     0x6449e9554b9f - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b
   7:     0x6449e95547c7 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44
   8:     0x6449e9552f39 - std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e
   9:     0x6449e9554454 - rust_begin_unwind
  10:     0x6449e9581313 - core::panicking::panic_fmt::h3d8fc78294164da7
  11:     0x6449e97e62b0 - tokio::runtime::task::raw::poll::h532ec3edeb01ad5a
  12:     0x6449eb7e5bb0 - std::sys::backtrace::__rust_begin_short_backtrace::h9b1417eeeba07a0f
  13:     0x6449eb7e69e2 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h17ee1c4af95c0f80
  14:     0x6449e955ba9b - std::sys::pal::unix::thread::Thread::new::thread_start::ha8af9c992ef0b208
  15:     0x789cfbe9ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  16:     0x789cfbf29c3c - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  17:                0x0 - <unknown>
```

</details>

<details>
<summary>Reproduction # 3 (Valid code, no error)</summary>

Input:

```svelte
<div
class="{arr.some((ele) => {
	switch (ele) {
		case 1:
			return true
		case 2:
			return true
		case 3:
			return true
	}
})
	? ''
	: 'hidden'}"
>
</div>

```

In this case, there's no trailing whitespace, and deno fmt successfully produce valid code

Output:

```svelte
<div
  class={arr.some((ele) => {
    switch (ele) {
      case 1:
        return true;
      case 2:
        return true;
      case 3:
        return true;
    }
  })
  ? ""
  : "hidden"}
>
</div>
```

</details>