[Svelte tip] Configuring svelte-check to only show errors (no warnings)

by Daniel Veihelmann, published on 10/30/2023

svelte-checkis Svelte's command line tool to check your Svelte files for errors, accessibility problems, unused CSS, and more.

It's a very handy tool to not only spot errors, but also to discover Svelte features and web standards (like accessibility standards) in general.

Why would you set svelte-check to "errors only" mode?

In some situations like a CI build jobs, you may want to limit the output of svelte-check to only errors and suppress warnings.

For example, the tool might raise legitimate but hard-to-fix warnings about accessibility issues that you don't want to fix right away.

How to set svelte-check to report errors only?

You can do this by passing the --threshold parameter, like this:

pnpm svelte-check --threshold error

This will also mean that a job won't fail if there are only warnings.

If for some reason you want the default behavior, you can also do --threshold warning to see errors and warnings (which is the default).

Personally, I'd recommend to only suppress in scenarios where you really have to (like the CI use case), because you will probably miss out on helpful warnings otherwise.

Lastly, you can also tell svelte-check to treat any warning as error. For this, simply pass the --fail-on-warnings flag.

That's it already - happy coding! 💻️


Need to review a complex merge request?

Let's get you some help! Simply paste your URL below:

Works with gitlab github