eslint-plugin-svelte3 icon indicating copy to clipboard operation
eslint-plugin-svelte3 copied to clipboard

vanilla setup doesn't enable type aware linting

Open indfnzo opened this issue 3 years ago • 1 comments

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.

indfnzo avatar Nov 18 '21 02:11 indfnzo

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

bamadesigner avatar Jan 31 '22 01:01 bamadesigner