sveltejs / eslint-plugin-svelte3

An ESLint plugin for Svelte v3 components.
MIT License
372 stars 43 forks source link

vanilla setup doesn't enable type aware linting #144

Open indfnzo opened 2 years ago

indfnzo commented 2 years ago

Global types and custom declarations aren't being detected during lint.

// src/global.d.ts
/// <reference types="@sveltejs/kit" />

declare interface CustomGlobalType {
    id: number;
    name: string;
}
<!-- src/index.svelte -->
<script lang="ts">
    const onClick: svelte.JSX.MouseEventHandler<HTMLButtonElement> = (evt) => {
        const object: CustomGlobalType = { id: 0, name: evt.currentTarget.innerText };
        alert(JSON.stringify(object));
    };
</script>

<button on:click={onClick}>Click Me</button>

Running npm run lint yields the following errors:

image

Repro: https://github.com/jemhuntr/svelte-type-aware-eslint


Project has been created with the most minimal setup possible.

npm init svelte@next svelte-type-aware-eslint
√ Which Svelte app template? » Skeleton project
√ Use TypeScript? ... No / Yes
√ Add ESLint for code linting? ... No / Yes
√ Add Prettier for code formatting? ... No / Yes

npm install --save-dev eslint-plugin-svelte3

Modified eslintrc based on README documentation, and made some small formatting/linting tweaks to fix lint errors ootb.

bamadesigner commented 2 years ago

I'm currently having the same exact issue. Would love to know if anyone has figured this out.