Skip to content

svelte/no-unnecessary-state-wrap cause unsolvable error with svelte(non_reactive_update) #1180

Closed
@gyzerok

Description

@gyzerok

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.23.0

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

3.4.1

What did you do?

In the following code snippet if I remove $state rune then I get svelte(non_reactive_update) error, however if I add it I get svelte/no-unnecessary-state-wrap.

Configuration
export default ts.config(
	includeIgnoreFile(gitignorePath),
	js.configs.recommended,
	...ts.configs.recommended,
	...svelte.configs.recommended,
	prettier,
	...svelte.configs.prettier,
	{
		languageOptions: {
			globals: { ...globals.browser, ...globals.node }
		},
		rules: { 'no-undef': 'off' }
	},
	{
		files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
		ignores: ['eslint.config.js', 'svelte.config.js'],
		languageOptions: {
			parserOptions: {
				projectService: true,
				extraFileExtensions: ['.svelte'],
				parser: ts.parser,
				svelteConfig
			}
		}
	}
);
<script lang="ts">
	import { SvelteSet } from 'svelte/reactivity';
	import Bug3 from './Bug3.svelte';

	let set = new SvelteSet<number>([]);

	$effect(() => {
		console.log(set);
	});
</script>

<Bug3 bind:set />

What did you expect to happen?

Not entirely sure

What actually happened?

Either of these errors

❯ npm run lint

> [email protected] lint
> prettier --check . && eslint .

Checking formatting...
All matched files use Prettier code style!

svelte-eslint-bug/src/routes/+page.svelte
  5:19  error  SvelteSet is already reactive, $state wrapping is unnecessary  svelte/no-unnecessary-state-wrap

✖ 1 problem (1 error, 0 warnings)
❯ npm run check

> [email protected] check
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json


====================================
Loading svelte-check in workspace: svelte-eslint-bug
Getting Svelte diagnostics...

/Users/f.nezhivoi/Code/work/svelte-eslint-bug/src/routes/+page.svelte:5:6
Warn: `set` is updated, but is not declared with `$state(...)`. Changing its value will not correctly trigger updates
https://svelte.dev/e/non_reactive_update (svelte)

        let set = new SvelteSet<number>([]);

====================================
svelte-check found 0 errors and 1 warning in 1 fil
``

### Link to **GitHub Repo** with Minimal Reproducible Example

Updated my repo with this issue: https://github.com/gyzerok/svelte-eslint-bug

### 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