Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Sveltekits A11y errors from [vite-plugin-svelte]

Is this new in Sveltekit July 2023? I've used Sveltekit many times and I opened some old components in a new sveltekit project and I'm getting a lot of Aria Role errors. I know I can use !-- svelte-ignore a11y-no-static-element-interactions --> but that works for only one component page. How can I disable all the errors popping up in my terminal? I don't agree with it, in general I simply don't want to follow the "rules". Do I make changes in vite.config.js, or svelte.config.js?

like image 209
Damon Medek Avatar asked Sep 13 '25 21:09

Damon Medek


1 Answers

Looks like there's an onwarn flag you can use in svelte.config.js, according to the vite-plugin-svelte docs:

export default defineConfig({
  plugins: [
    svelte({
      onwarn(warning, defaultHandler) {
        // don't warn on <marquee> elements, cos they're cool
        if (warning.code === 'a11y-distracting-elements') return;

        // handle all other warnings normally
        defaultHandler(warning);
      }
    })
  ]
});

That's the example from the docs, clearly you'd update the warning:

export default defineConfig({
  plugins: [
    svelte({
      onwarn(warning, defaultHandler) {
        if (warning.code === 'a11y-no-static-element-interactions') return;

        // handle all other warnings normally
        defaultHandler(warning);
      }
    })
  ]
});
like image 76
Chris Cozens Avatar answered Sep 17 '25 19:09

Chris Cozens