2026-03-11 16:44:55 +07:00
|
|
|
# Style and Conventions
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
Primary source: `AGENTS.md`.
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
## JavaScript/TypeScript style
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
- 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 `@param` and `@returns`.
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
## Import ordering
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
1. Svelte / `$app/*`
|
|
|
|
|
2. `$lib/*`
|
|
|
|
|
3. External libraries (e.g., `lucide-svelte`)
|
|
|
|
|
4. Relative imports (minimize, prefer `$lib`)
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
## Naming
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
- 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.
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
## Svelte 5 patterns
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
- 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/environment` `browser` checks.
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
## API/store patterns
|
2026-03-09 06:59:36 +07:00
|
|
|
|
2026-03-11 16:44:55 +07:00
|
|
|
- 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`).
|