Closed as not planned
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?
^8.56.0
What version of eslint-plugin-svelte
are you using?
^2.35.1
What did you do?
Configuration
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
plugins: ['prettier', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2022
},
env: {
browser: true,
es2017: true,
node: true
},
globals: {
gtag: true,
__version__: true
},
overrides: [
{
files: ['*.svelte'], // Apply these settings to Svelte files
parser: 'svelte-eslint-parser', // Use the Svelte parser for .svelte files
parserOptions: {
parser: '@typescript-eslint/parser' // Use TypeScript parser for inside <script> blocks
}
}
],
rules: {
'prettier/prettier': 'error',
'quotes': ['warn', 'single', { avoidEscape: true }],
'no-console': 'off',
'no-tabs': 'off',
'no-restricted-syntax': 'off',
'func-names': 'off',
'quote-props': ['error', 'consistent-as-needed'],
'guard-for-in': 'off',
'import/extensions': 'off',
'new-cap': 'off',
'import/no-extraneous-dependencies': 'off',
'no-param-reassign': 'off',
'radix': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'prefer-const': 'error',
'svelte/no-at-html-tags': 'off',
// Not designed to work with typescript; turned off in favor of typescript-eslint rules
'no-undef': 'off',
'no-unused-vars': 'off',
// Unused vars must start with `_`
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// TODO: remove below
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off'
}
};
<script lang="ts">
import type { ChangeEventHandler } from 'svelte/elements';
// Necessary because we forward the `on:change` event
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface $$Events {
change: Parameters<ChangeEventHandler<HTMLInputElement>>[0];
}
export let checked: null | boolean = false;
export let id: string;
export let labelText: string;
</script>
<div>
<div>
<input bind:checked type="checkbox" {id} on:change />
<label for={id} class="toggle-bg" />
</div>
<label for={id}>
{labelText}
</label>
</div>
What did you expect to happen?
This should not be an error since $$Events is necessary for on:change and otherwise I get errors from Typescript and when running check
:
svelte-check --tsconfig ./tsconfig.json
Error: Property 'checked' does not exist on type 'EventTarget'. (ts)
on:change={(e) => {
if (e.currentTarget.checked) {
What actually happened?
Toggle.svelte
5:12 error '$$Events' is defined but never used @typescript-eslint/no-unused-vars
Link to GitHub Repo with Minimal Reproducible Example
Additional comments
Thank you in advance