Skip to content

Instantly share code, notes, and snippets.

@babakfp
Last active April 20, 2024 23:43
Show Gist options
  • Save babakfp/ba36a8e8d4ddee5d32c1a8b6b14586f4 to your computer and use it in GitHub Desktop.
Save babakfp/ba36a8e8d4ddee5d32c1a8b6b14586f4 to your computer and use it in GitHub Desktop.
Get rid of Svelte and SvelteKit a11y errors in vsCode editor and console

Put it into your vsCode JSON config:

{
  "svelte.plugin.svelte.compilerWarnings": {
      "a11y-accesskey": "ignore",
      "a11y-aria-activedescendant-has-tabindex": "ignore",
      "a11y-aria-attributes": "ignore",
      "a11y-autofocus": "ignore",
      "a11y-click-events-have-key-events": "ignore",
      "a11y-distracting-elements": "ignore",
      "a11y-hidden": "ignore",
      "a11y-img-redundant-alt": "ignore",
      "a11y-incorrect-aria-attribute-type": "ignore",
      "a11y-invalid-attribute": "ignore",
      "a11y-interactive-supports-focus": "ignore",
      "a11y-label-has-associated-control": "ignore",
      "a11y-media-has-caption": "ignore",
      "a11y-misplaced-role": "ignore",
      "a11y-misplaced-scope": "ignore",
      "a11y-missing-attribute": "ignore",
      "a11y-missing-content": "ignore",
      "a11y-mouse-events-have-key-events": "ignore",
      "a11y-no-redundant-roles": "ignore",
      "a11y-no-interactive-element-to-noninteractive-role": "ignore",
      "a11y-no-noninteractive-tabindex": "ignore",
      "a11y-no-static-element-interactions": "ignore",
      "a11y-positive-tabindex": "ignore",
      "a11y-role-has-required-aria-props": "ignore",
      "a11y-role-supports-aria-props": "ignore",
      "a11y-structure": "ignore",
      "a11y-unknown-aria-attribute": "ignore",
      "a11y-unknown-role": "ignore",
      "avoid-mouse-events-on-document": "ignore"
  },
}

in SvelteKit svelte.config.js file:

const config = {
    onwarn: (warning, handler) => {
        if (warning.code.startsWith("a11y-")) return
        handler(warning)
    },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment