1.3 KiB
1.3 KiB
Style and Conventions
Primary source: AGENTS.md.
JavaScript/TypeScript style
- Use ES modules (
import/export). - Semicolons required.
- Single quotes for strings.
- 2-space indentation.
- Trailing commas in multi-line arrays/objects.
- Document exported functions with JSDoc including
@paramand@returns.
Import ordering
- Svelte /
$app/* $lib/*- External libraries (e.g.,
lucide-svelte) - Relative imports (minimize, prefer
$lib)
Naming
- Components: PascalCase (
LoginForm.svelte) - Route/files: lowercase with hyphens
- Variables/stores: camelCase
- Constants: UPPER_SNAKE_CASE
- Event handlers:
handle... - Form state fields:
formLoading,formError, etc.
Svelte 5 patterns
- Follow component script order: imports -> props -> state -> derived -> effects -> handlers.
- Prefer DaisyUI component classes (
btn,input,card, etc.). - For icon inputs, use DaisyUI label+input flex pattern (not absolute-positioned icons).
- Access browser-only APIs behind
$app/environmentbrowserchecks.
API/store patterns
- Use shared API helpers from
$lib/api/client.js(get/post/put/patch/del). - Build query strings using
URLSearchParams. - Use try/catch with toast error/success utilities.
- LocalStorage keys should be descriptive (e.g.,
clqms_username,auth_token).