Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot ignore svelte lint warnings in the script block #2354

Open
ottomated opened this issue Apr 28, 2024 · 6 comments
Open

Cannot ignore svelte lint warnings in the script block #2354

ottomated opened this issue Apr 28, 2024 · 6 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@ottomated
Copy link

Describe the bug

If you quick fix a lint warning in a script block, it inserts an HTML comment at the bottom instead of a JS comment in the right place.

Reproduction

<script>
   let s = $state(0);
   console.log(s);
//             ^
// State referenced in its own scope will never update.
// Did you mean to reference it inside a closure?
// svelte(static_state_reference)
</script>

<!-- using the quick fix inserts this line -->
<!-- svelte-ignore static_state_reference -->
<p>{s}</p>

Expected behaviour

Desired output:

<script>
   let s = $state(0);
   // svelte-ignore static_state_reference
   console.log(s);
</script>

<p>{s}</p>

Note also that adding the comment manually does not work either.

System Info

  • OS: Linux
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@ottomated ottomated added the bug Something isn't working label Apr 28, 2024
@jasonlyu123
Copy link
Member

jasonlyu123 commented May 13, 2024

Regarding the "Expected behaviour" part, the svelte-ignore comment can only be an HTML comment. If you wish to be able to only suppress specific lines inside the script tag, please open an issue in the main svelte repo.

@jasonlyu123
Copy link
Member

Ah. Ignore my previous comment. The js comment does work. But the warning code got renamed a few weeks before so maybe you're referencing the old code?

@ottomated
Copy link
Author

@jasonlyu123 This is still an issue - you can see the line here where it inserts an html comment. This should insert a JS comment if it's in the JS part of the code.

@jasonlyu123
Copy link
Member

I didn't say it wasn't. I was addressing the "adding the comment manually does not work either" part.

@ottomated
Copy link
Author

Got it, it seems like that has been fixed since my original issue yes

@jasonlyu123
Copy link
Member

The quick fix is fixed in #2531, Release pending.

@jasonlyu123 jasonlyu123 added the Fixed Fixed in master branch. Pending production release. label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants