Development Guide
Panduan best practices untuk development di MStore Dashboard.Development Workflow
Starting Development
Code Generation
Saat membuat perubahan pada types atau schema:Project Structure Best Practices
Feature Module Structure
Setiap feature module harus mengikuti struktur ini:Barrel Exports
Selalu gunakan barrel exports untuk clean imports:Naming Conventions
Files
| Type | Convention | Example |
|---|---|---|
| Page | kebab-case | inventory-list.vue |
| Component | PascalCase | InventoryTable.vue |
| Composable | camelCase | useInventoryList.ts |
| Store | kebab-case | inventory.store.ts |
| Type | kebab-case | inventory.types.ts |
| API | camelCase | getList.ts |
Code
| Type | Convention | Example |
|---|---|---|
| Component | PascalCase | InventoryTable |
| Composable | usePascalCase | useInventoryList |
| Store | usePascalCaseStore | useInventoryStore |
| Function | camelCase | getInventoryList |
| Interface | PascalCase | Inventory |
| Type | PascalCase | InventoryStatus |
| Constant | SCREAMING_SNAKE_CASE | MAX_ITEMS |
TypeScript Best Practices
Always Type Everything
Use Strict Mode
Prefer Interfaces Over Types
Vue 3 Best Practices
Composition API
Always use Composition API with<script setup>:
Props & Emits Typing
Use v-model Properly
State Management Best Practices
Store Organization
Composable vs Store
| Use Case | Use Store | Use Composable |
|---|---|---|
| Shared across pages | ✅ | ❌ |
| Single page only | ❌ | ✅ |
| Need persistence | ✅ | ❌ |
| Form state | ❌ | ✅ |
| UI state | ❌ | ✅ (or ref) |
API Best Practices
Error Handling
Component Best Practices
Single Responsibility
Props Down, Events Up
Performance Tips
Lazy Loading
Virtual Scrolling
Untuk list besar, gunakan virtual scrolling:Computed Caching
Debugging
Vue DevTools
- Install Vue DevTools browser extension
- Inspect component hierarchy
- Debug Pinia stores
- Track events
Vue Inspector
Console Logging
Common Patterns
Loading State Pattern
Form Pattern
Checklist for New Features
- Create feature folder structure
- Define types in
types/ - Create API functions in
api/ - Create Pinia store in
store/ - Create composables in
composables/ - Create components in
components/ - Create barrel exports in
index.ts - Create page in
app/pages/ - Add translations in
locales/ - Write tests (if applicable)
- Update documentation