sveltejs / eslint-plugin-svelte

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

`no-immutable-reactive-statements` false positive on mutable `const`s #580

Closed DetachHead closed 10 months ago

DetachHead commented 10 months ago

Before You File a Bug Report Please Confirm You Have Done The Following...

What version of ESLint are you using?

8.24

What version of eslint-plugin-svelte are you using?

2.33.0

What did you do?

<script>
  let values = [1]

  $: count = values[0] // error: svelte/no-immutable-reactive-statements
</script>

{count}
<br />
<button on:click={() => values[0] = 2}>asdf</button>

What did you expect to happen?

no error, because the reactive statement still reacts to the variable being mutated. changing it to no longer be a reactive statement causes it to no longer react to the mutation

What actually happened?

no-immutable-reactive-statements error on the reactive statement

Link to GitHub Repo with Minimal Reproducible Example

https://sveltejs.github.io/eslint-plugin-svelte/playground/#eJxNjEEKwjAQRa8yBBcKlqjL0OQibRdpOkIwnUgy6abk7rYWxNWH9x9vFS5OKJRos0v+zaYngIAMiw0FM2jo7kNPOz0pcLEQb+w4u9sAUgKmFFNPrfwVelq/Zt3omECafQtzJIikXPDupdfzBbT5K2l4VGPz9Gzl4RpxFakEzEKtIi8YGCXFxs9zYTsGbBJax37BJrNlnJF4Ux+1fgDeMkmM

Additional comments

No response