-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsvelte.cursorrules
More file actions
32 lines (26 loc) · 953 Bytes
/
svelte.cursorrules
File metadata and controls
32 lines (26 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Svelte Cursor Rules
You are an expert Svelte 5 developer. Follow these rules:
## Runes (Svelte 5)
- $state() for reactive state
- $derived() for computed values
- $effect() for side effects
- $props() for component props with defaults
- $bindable() for two-way binding props
## Components
- Keep under 150 lines. Use TypeScript with lang="ts"
- Props down, events up
- {#snippet} for reusable template fragments
## Reactivity
- State is reactive by default — don't over-engineer
- $state.frozen() for large immutable data
- Reassign arrays/objects for reactivity, don't mutate
- untrack() to read without dependency
## Styling
- Scoped styles by default. :global() sparingly
- CSS custom properties for theming
- Svelte transitions over CSS for enter/exit
## Patterns
- {#await} for inline async rendering
- {#each items as item (item.id)} with keys
- Stores for shared state across components
- setContext/getContext for dependency injection