# svelte/no-unused-svelte-ignore

disallow unused svelte-ignore comments

  • βš™οΈ This rule is included in "plugin:svelte/recommended".

# πŸ“– Rule Details

This rule warns unnecessary svelte-ignore comments.

svelte-ignore comments can include an explanatory note in parentheses after the warning names. This rule checks only the warning names and ignores the explanatory note.

<script>
  /* eslint svelte/no-unused-svelte-ignore: "error" */
</script>

<!-- βœ“ GOOD -->
<!-- svelte-ignore a11y-autofocus a11y-missing-attribute -->
<img src="https://example.com/img.png" autofocus />

<!-- svelte-ignore a11y-autofocus, a11y-missing-attribute (intentional for this example) -->
<img src="https://example.com/img.png" autofocus />

<!-- βœ— BAD -->
<!-- svelte-ignore 
svelte-ignore comment is used, but not warned (svelte/no-unused-svelte-ignore)
a11y-autofocus
svelte-ignore comment is used, but not warned (svelte/no-unused-svelte-ignore)
a11y-missing-attribute -->
<img src="https://example.com/img.png" alt="Foo" />

# Runtime warnings

Svelte v5 also lets you use svelte-ignore to silence some runtime warnings, such as ownership_invalid_binding. The compiler never reports these warnings, so this rule can’t tell whether the comment is used. This rule doesn’t report these codes, even if the comment is in the wrong place.

But in runes mode, Svelte ignores some of these codes, so this rule still reports them:

  • The kebab-case form (e.g. ownership-invalid-binding).
  • Codes after a code that isn’t followed by a comma. Svelte reads the rest of the comment as prose (e.g. ownership_invalid_binding in svelte-ignore a11y_autofocus ownership_invalid_binding).

# πŸ”§ Options

Nothing.

# πŸ“š Further Reading

# πŸš€ Version

This rule was introduced in eslint-plugin-svelte v0.19.0

# πŸ” Implementation