-
-
Notifications
You must be signed in to change notification settings - Fork 57
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.35.0
What version of eslint-plugin-svelte
are you using?
3.12.2
What did you do?
I'd like to use the rules from the strictTypeChecked
eslint config in my SvelteKit projects. I've created a minimal reproduction using sv create
in which I've demonstrated the various adjustments I've had to make to get this config to work. However, even with these adjustments, there are still problems.
Adding this block to eslint.config.js
allows me to use the strict typechecked rules in TypeScript and Svelte files:
{
files: ['**/*.ts', '**/*.svelte'],
extends: [...ts.configs.strictTypeChecked],
languageOptions: {
parserOptions: {
project: ['./tsconfig.json']
}
}
},
However, then I get parsing errors in the Svelte files when I run eslint:
/<redacted>/svelte-eslint-strict-typechecked-demo/src/routes/+layout.svelte
1:8 error Parsing error: '>' expected
/<redacted>/svelte-eslint-strict-typechecked-demo/src/routes/+page.svelte
1:8 error Parsing error: '>' expected
Omitting the base config (the first item in the array) resolves the parsing errors: ...ts.configs.strictTypeChecked.slice(1)
However, then I get inconsistent behavior in Svelte files:
<script lang="ts">
const emptyString = '';
// This results in an error due to @typescript-eslint/no-unnecessary-condition
if (emptyString) {
console.log('test');
}
</script>
<!-- This does not result in an error -->
{#if emptyString}
<p>test</p>
{/if}
Is this a bug with eslint-plugin-svelte, or is a different configuration needed in order for the strict typechecked rules to be applied correctly?
What did you expect to happen?
What actually happened?
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/DePasqualeOrg/svelte-eslint-strict-typechecked-demo
Additional comments
No response