vue.mdc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ---
  2. description:
  3. globs:
  4. alwaysApply: true
  5. ---
  6. ---
  7. description: Vue.js best practices and patterns for modern web applications
  8. globs: **/*.vue, **/*.ts, components/**/*
  9. ---
  10. # Vue.js Best Practices
  11. ## Component Structure
  12. - Use Composition API over Options API
  13. - Keep components small and focused
  14. - Use proper TypeScript integration
  15. - Implement proper props validation
  16. - Use proper emit declarations
  17. - Keep template logic minimal
  18. ## Composition API
  19. - Use proper ref and reactive
  20. - Implement proper lifecycle hooks
  21. - Use composables for reusable logic
  22. - Keep setup function clean
  23. - Use proper computed properties
  24. - Implement proper watchers
  25. ## State Management
  26. - Use Pinia for state management
  27. - Keep stores modular
  28. - Use proper state composition
  29. - Implement proper actions
  30. - Use proper getters
  31. - Handle async state properly
  32. ## Performance
  33. - Use proper component lazy loading
  34. - Implement proper caching
  35. - Use proper computed properties
  36. - Avoid unnecessary watchers
  37. - Use proper v-show vs v-if
  38. - Implement proper key management
  39. ## Forms
  40. - Use v-model properly
  41. - Implement proper validation
  42. - Handle form submission properly
  43. - Show proper loading states
  44. - Use proper error handling
  45. - Implement proper form reset
  46. ## TypeScript Integration
  47. - Use proper component type definitions
  48. - Implement proper prop types
  49. - Use proper emit declarations
  50. - Handle proper type inference
  51. - Use proper composable types
  52. - Implement proper store types
  53. ## Testing
  54. - Write proper unit tests
  55. - Implement proper component tests
  56. - Use Vue Test Utils properly
  57. - Test composables properly
  58. - Implement proper mocking
  59. - Test async operations
  60. ## Best Practices
  61. - Follow Vue style guide
  62. - Use proper naming conventions
  63. - Keep components organized
  64. - Implement proper error handling
  65. - Use proper event handling
  66. - Document complex logic