Skip to content

no-unnecessary-state-wrap triggers too often #1154

Open
@benmccann

Description

@benmccann

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

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

3.3.3

What did you do?

Tried to upgrade https://github.com/immich-app/immich/tree/main/web to 3.3.3

It triggered no-unnecessary-state-wrap in two places. One was helpful, but the other I consider to be a false positive

What did you expect to happen?

This shouldn't be $state and should be a const: https://github.com/immich-app/immich/blob/392ce7deb2683d2c66a821c617329b3641491016/web/src/lib/components/forms/tag-asset-form.svelte#L21

However, this one is pretty reasonable because you're creating a new SvelteSet and it's a lot more cumbersome to clear the set and then add each item: https://github.com/immich-app/immich/blob/90f21d9047aa33dcb8231ab61269e60a32aedd9f/web/src/lib/components/utilities-page/duplicates/duplicates-compare-control.svelte#L86

I think we should trigger the rule only when the variable is not being reassigned

What actually happened?

It said that I should not use $state in either location.

Link to GitHub Repo with Minimal Reproducible Example

The full repo is here: https://github.com/immich-app/immich/tree/main/web

I can create a smaller version if needed

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions