-
-
Notifications
You must be signed in to change notification settings - Fork 59
fix(prefer-destructured-store-props): handle runes properly #1440
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
Conversation
🦋 Changeset detectedLatest commit: c3643d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Try the Instant Preview in Online PlaygroundInstall the Instant Preview to Your LocalPublished Instant Preview Packages:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the prefer-destructured-store-props ESLint rule to properly handle Svelte 5 runes. The rule was incorrectly flagging rune member expressions (like $state.raw, $derived.by, $effect.pre) as stores that should be destructured. The fix adds logic to skip these Svelte 5 runes when the runes mode is enabled.
Key changes:
- Added
SVELTE_RUNESset containing Svelte 5 rune identifiers that should be excluded from store destructuring checks - Added conditional check to skip rune member expressions when
runes === true - Added test cases to verify runes are properly handled while actual stores are still caught
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/eslint-plugin-svelte/src/rules/prefer-destructured-store-props.ts | Core fix: imports getSvelteContext, defines SVELTE_RUNES set, and adds check to skip rune member expressions when runes are enabled |
| packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/valid/runes01-input.svelte.js | Valid test case showing Svelte 5 rune usage in a class |
| packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/valid/runes01-requirements.json | Specifies Svelte 5+ requirement for the valid test |
| packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/invalid/runes-with-store01-input.svelte | Invalid test case verifying stores are still flagged when runes are present |
| packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/invalid/runes-with-store01-requirements.json | Specifies Svelte 5+ requirement for the invalid test |
| packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-destructured-store-props/invalid/runes-with-store01-errors.yaml | Expected error and autofix suggestion for the invalid test case |
| .changeset/wet-kiwis-cover.md | Changeset documenting the patch-level fix |
Comments suppressed due to low confidence (1)
packages/eslint-plugin-svelte/src/rules/prefer-destructured-store-props.ts:26
- The
SVELTE_RUNESset is missing$restProps, which is a built-in reactive variable in Svelte 5 that should also be excluded from this rule. When$restPropsis used (e.g.,{$restProps.foo}), it shouldn't be flagged for destructuring as it's a Svelte-managed reactive object, not a user-defined store.
Add '$restProps' to the set.
description:
'destructure values from object stores for better change tracking & fewer redraws',
category: 'Best Practices',
recommended: false
},
hasSuggestions: true,
schema: [],
messages: {
useDestructuring: `Destructure {{property}} from {{store}} for better change tracking & fewer redraws`,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
close: #1433