Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: do not run no-reactive-reassign rule on Svelte 5 with runes #1014

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

baseballyama
Copy link
Member

@baseballyama baseballyama commented Jan 12, 2025

The Svelte 5 compiler throws an error if a $derived value is reassigned. For object values, it’s better to use const instead of let. This will be addressed by #985

<script>
  let count = $state(1);
	let double = $derived(count * 2);

	let obj = $state({ foo: 1 });
	let derivedObj = $derived( { ...obj, bar: true });

	function invalid() {
		double = double + 1;
		derivedObj.bar = false;
	}
</script>

https://svelte.dev/playground/hello-world?version=5.17.3#H4sIAAAAAAAAE22PwU7EMAxEf8WyOLRQBZVjdheJGzc-gHBIGlfKKptUiVtAVf8dZdstHLhZM2_G9oxBXwglvpL3ET5j8hYqso7J1thg7zxllO8z8vdQuCJgc0u9DIPIE3kumtGZ_tO7GJgCZ5R4zF1yAz-rAOCJoYtjYDjBXWbNVLX1QQXFxbFxNJ6KZSm5iWy1svfwdIU2LJrzb3yGPkYJLSx_etb028rdumAGIUQ05waMThI4jbSlguJ-DB27GMCFSXtnqxrmoiver9qGB2gPm7PvEUYnOEGvfaaruahwfNwfxwaZvhhl2bl8LD9gOIRsggEAAA==

Copy link

pkg-pr-new bot commented Jan 12, 2025

Open in Stackblitz

npm i https://pkg.pr.new/eslint-plugin-svelte@1014

commit: b4eb6bf

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants