sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
296 stars 35 forks source link

Suggestion: Override `init-declarations` #684

Open marekdedic opened 7 months ago

marekdedic commented 7 months ago

Hi, the ESLint rule init-declarations looks for unitialized variable declarations such as

let myVar;

This is certainly useful (although a matter of opinion, which is why it isn't in the recommended set I believe), but breaks with Svelte, because in Svelte, there are export declarations with special meaning such as

<script>
  export let propWithoutDefault;
</script>

{propWithoutDefault}

The rule triggers for these as well, which is incorrect. I don't know what the correct fix is (I can imagine adding an override rule or fixing it in the parser so that the export declarations are not checked by rules checking for declarations, but that would probably create more issues).

There is also an extended @typescript-eslint/init-declarations rule, which probably further complicates the matter...