This is a guide on how to ignore compiler warnings in SvelteKit.
🤨 Why would I want to ignore SvelteKit warnings?
Let me start off by saying that I'm writing this article not because I don't care about accessibility.
There are just some SvelteKit warnings that I prefer not to pay attention to. I think most of the accessibility warnings are pretty good though. One of those is this:
Rich Harris opened this issue in April 3, 2024 on "Svelte parses HTML all wrong". Ever since that, I've been getting a lot of warnings for something I prefer to do:
If you're coming from JSX-based frameworks like React and Solid, you might be used to self-closing tags for elements with no children.
🚀 Follow these steps:
- First, find out the name of the warning.
You can do this pretty easily by using the onwarn callback in your svelte.config.js
file.
You will see something like this. Take note of the code property.
For my case it's element_invalid_self_closing_tag
.
- Ignore the compiler warning.
You can easily ignore it by early returning from the onwarn callback.
You won't see this warning the console anymore.
- Ignore the warning in your code.
If you're using VSCode, you still might see this.
I recommend doing Ctrl
+ Shift
+ P
and finding Preferences: Open Workspace Settings (JSON)
. Then type this in your config.
🎉 That's it, you're done! Hope this helps you!