denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.21k stars 5.41k forks source link

deno fmt errors on multiline string embedded in HTML <script> #26407

Open mfulton26 opened 1 month ago

mfulton26 commented 1 month ago

Formatting works fine without the \ and newline but not with them.

<!-- demo.html -->
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Demo</title>
  </head>
  <body>
    <script type="module">
      const supportedFormats =
        await globalThis.BarcodeDetector?.getSupportedFormats() ?? [];
      if (!supportedFormats.includes("qr_code")) {
        document.body.innerHTML +=
          '<p><a \
href="https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector">QR Code detection</a> is not natively supported by your web browser. 😔</p>';
      }
    </script>
  </body>
</html>
% RUST_BACKTRACE=1 deno fmt demo.html

============================================================
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: macos aarch64
Version: 2.0.2
Args: ["deno", "fmt", "demo.html"]

thread 'tokio-runtime-worker' panicked at cli/tools/fmt.rs:792:11:
Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file (/path/to/demo.html) differently each time. As a temporary workaround you can ignore this file.
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: tokio::runtime::task::raw::poll
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
bartlomieju commented 3 weeks ago

Caused by https://github.com/dprint/dprint-plugin-typescript/issues/678.