Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I'm using eslint-plugin-svelte. (
*.svelte
file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.) - I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte repo if there is no solution.
- 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
and svelte-eslint-parser
are you using?
- eslint-plugin-svelte@2.39.0
What did you do?
Configuration
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};
src/lib/foo.svelte
<script>
const { foo } = $props();
</script>
<div>
{@render foo()}
</div>
src/page/+page.svelte
<script>
import Foo from '$lib/foo.svelte';
</script>
{#snippet foo()}
{#snippet bar()}Bar{/snippet}
Foo {@render bar()}
{/snippet}
<Foo {foo} />
What did you expect to happen?
No error
What actually happened?
pnpm lint
> nested-snippet-linter-error@0.0.1 lint nested-snippet-linter-error
> prettier --check . && eslint .
Checking formatting...
All matched files use Prettier code style!
nested-snippet-linter-error/src/routes/+page.svelte
0:0 error Parsing error: Cannot read properties of undefined (reading 'length')
✖ 1 problem (1 error, 0 warnings)
ELIFECYCLE Command failed with exit code 1.
However, issue in another project was even more cryptic but I can't recreate in minimal example
...src/routes/+page.svelte
0:0 error Parsing error: fnDecl.params is not iterable
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/vojtechsimetka/nested-snippet-linter-error
Additional comments
Same happens with eslint@9