sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
76.8k stars 3.98k forks source link

Svelte 5: behavior of svelte-ignore is different between Svelte 4 and Svelte 5 #11482

Closed baseballyama closed 4 days ago

baseballyama commented 1 week ago

Describe the bug

In Svelte 4, if we wrote <!-- svelte-ignore —>, warnings that occur on child elements were also ignored, but Svelte 5 is not.

Reproduction

Svelte 4: https://svelte.dev/repl/6e5aed69999a482cbd33c8370d33b05e?version=4.2.15 Svelte 5: https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE2WPwUrEMBBAfyWOF4XGuuKpxIL4A96NhGwzuw6mk5JMq0vpv0tbPXmceY83zAwniligeZuBfY_QwPMwQAVyGdahTBgFoYKSxtytGxNoai1bMVdaq51rOnPKqPzhcHGcHCcmFsy-E5rQiT8SB_yudiH6I0b34YvzpaSOvGBwXWLJKSqtt_h87b88iXrNqaeCdxlLihPePD7cLiu3YraM-ms_Wbi30L5E6j5NvbH2Vxz_WaYedzrX25nFsqnXv6CCPgU6EQZoJI-4vC8_ZPo62iMBAAA=

Logs

No response

System Info

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 171.27 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.1 - ~/.nodenv/versions/20.12.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.5.2 - ~/.nodenv/versions/20.12.1/bin/npm
    pnpm: 8.15.7 - ~/.nodenv/versions/20.12.1/bin/pnpm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 124.0.6367.119
    Edge: 124.0.2478.80
    Safari: 17.2.1
  npmPackages:
    svelte: ^5.0.0-next.112 => 5.0.0-next.123

Severity

annoyance

baseballyama commented 1 week ago

Sorry, this is because there is comma between warning messages.

baseballyama commented 1 week ago

But I found a strange pattern, so I'll reopen it. But I think this can be marked it as a breaking change instead of updating compiler.

Svelte 4 (Ignore warnings properly)

https://svelte.dev/repl/98c0dfc386d34e5ea8d15c8a7b1e54df?version=4.2.15

<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
TEXT
<div class="dropdown">
    <label tabindex="0">Click</label>
    <ul tabindex="0"></ul>
</div>

Svelte 5 (warnings are not ignored)

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE2WNwWrDMBBEf0Xds4Wbq1EMpfQPcih0i1CkTbtU2TWS7DaE_HtxTE89zps3zBVOnKnC8HYFCWeCAZ6mCTpol2kNdaHcCDqoOpe4Evdgrdmw5Q_RQibsdhefw5Gy_wzVh1o1cmiUfFRpRfNmiHpRYWlUQmy8kG_hyJLox1g7ohxeXg8oLvFiYg617hFS0SnptyCMKNjc_cT8zfYIjwjjc-b45fp7t2nzP8f189q5PvEyokAHZ018YkowtDLT7f32C6xAdA8LAQAA

<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
TEXT
<div class="dropdown">
    <label tabindex="0">Click</label>
    <ul tabindex="0"></ul>
</div>
JorensM commented 1 week ago

But I found a strange pattern, so I'll reopen it. ~But I think this can be marked it as a breaking change instead of updating compiler.~ ~-> Oh, now we can not specify svelte-ignore for the entire file. Therefore I think we need to fix this issue?~ -> Only Text node has this issue.

Svelte 4 (Ignore warnings properly)

https://svelte.dev/repl/98c0dfc386d34e5ea8d15c8a7b1e54df?version=4.2.15

<!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
TEXT
<div class="dropdown">
  <label tabindex="0">Click</label>
  <ul tabindex="0"></ul>
</div>

Svelte 5 (warnings are not ignored)

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE2WNwWrDMBBEf0Xds4Wbq1EMpfQPcih0i1CkTbtU2TWS7DaE_HtxTE89zps3zBVOnKnC8HYFCWeCAZ6mCTpol2kNdaHcCDqoOpe4Evdgrdmw5Q_RQibsdhefw5Gy_wzVh1o1cmiUfFRpRfNmiHpRYWlUQmy8kG_hyJLox1g7ohxeXg8oLvFiYg617hFS0SnptyCMKNjc_cT8zfYIjwjjc-b45fp7t2nzP8f189q5PvEyokAHZ018YkowtDLT7f32C6xAdA8LAQAA

<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
TEXT
<div class="dropdown">
  <label tabindex="0">Click</label>
  <ul tabindex="0"></ul>
</div>

So I'm guessing the ignore comment on the second preview is not working because it's expecting to have an element right below the comment. But if the ignore comment is on the first line of the file, then the warnings for the entire file should be ignored, is that right?