-
-
Notifications
You must be signed in to change notification settings - Fork 59
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
What version of ESLint are you using?
9.21.0
What version of eslint-plugin-svelte are you using?
3.0.2
What did you do?
Configuration
Default config made by `sv create`:import js from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));
/** @type {import('eslint').Linter.Config[]} */
export default [
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...svelte.configs["flat/recommended"],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
}
];
I often use web components, so I have to ignore a11y_click_events_have_key_events and a11y_no_static_element_interactions rules, because they are false-positive (web components I use are not static and usually it's enough to have only onclick on them).
<!-- REPORTED by svelte-check, NOT reported by eslint-plugin-svelte -->
<my-web-component onclick={() => {}}></my-web-component>
<!-- NOT reported by both -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<my-web-component onclick={() => {}}></my-web-component>
<!-- NOT reported by svelte-check, REPORTED svelte/no-unused-svelte-ignore by eslint-plugin-svelte -->
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
<my-web-component onclick={() => {}}></my-web-component>What did you expect to happen?
Default eslint-plugin-svelte rules should be consistent to itself:
- If line 2 is not reported, then both 7 and 10 lines should be reported.
- If line 2 is reported, then both lines 7 and 10 should be not.
Maybe, by default it should not report on rules which are not reported by svelte-check. In this case, eslint-plugin-svelte should report the line # 2, and not on any other line.
What actually happened?
In the example above, eslint-plugin-svelte output is inconsistent not only to svelte-check, but also to eslint-plugin-svelte itself:
If the line # 10 has unused svelte-ignore, why the 7th line does not have it? It has completely same set of svelte-ignores.
If line # 7 has correct ignores, why the line # 2 is not reported?
eslint-plugin-svelte:
/Users/pnedrigailov/workspace/tmp/unused/src/routes/+page.svelte
10:20 error svelte-ignore comment is used, but not warned svelte/no-unused-svelte-ignore
svelte-check:
/Users/pnedrigailov/workspace/tmp/unused/src/routes/+page.svelte:2:1
Warn: Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type="button">` or `<a>` might be more appropriate
https://svelte.dev/e/a11y_click_events_have_key_events (svelte)
<!-- REPORTED by svelte-check, NOT reported by eslint-plugin-svelte: -->
<my-web-component onclick={() => {}}></my-web-component>
/Users/pnedrigailov/workspace/tmp/unused/src/routes/+page.svelte:2:1
Warn: `<my-web-component>` with a click handler must have an ARIA role
https://svelte.dev/e/a11y_no_static_element_interactions (svelte)
<!-- REPORTED by svelte-check, NOT reported by eslint-plugin-svelte: -->
<my-web-component onclick={() => {}}></my-web-component>
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/shadow-identity/reproduction-eslint-plugin-svelte-inconsistancy
Additional comments
No response