eslint-plugin-svelte
eslint-plugin-svelte copied to clipboard
feat: Add svelte/prefer-const rule that excludes reactive variables
The const declaration creates an immutable reference to a value. The variable identifier cannot be reassigned. You should understand const declarations as "create a variable whose identity remains constant"
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
The ESLint prefer-const doesn't take into account that Svelte's reactivity system is reassigning reactive variables.
The svelte/prefer-const rule skip variables that are created by runes like $props, $derived, $derived.by, etc.
Companion to the rune-prefer-let rule.
🦋 Changeset detected
Latest commit: 5c29c5cc180f8e72843eaf58ecb6ad92b760ae5f
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| eslint-plugin-svelte | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Could you please propose the rule in a new issue first?
@ota-meshi and @baseballyama, we could close this PR already.
Close in favor of https://github.com/sveltejs/eslint-plugin-svelte/pull/933