Enable code lint in Svelte components
svelte in the
When initializing a SvelteKit project using
npm init svelte, there is an option to add ESLint for code linting. If TypeScript is selected for type checking, TypeScript ESLint is installed and configured by default as well.
However, code inside
<script lang=”ts”> are not validated by default. For example, unused variables do not show any error, even though
no-unused-vars is enabled. (
ts does show relevant information though)
svelte files to be validated by ESLint,
variable is assigned a value but never used error message is shown with a yellow underline.