.cursorrules 2.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. You are an expert in TypeScript, Node.js, Vite, Vue.js, Vue Router, Pinia, VueUse, Headless UI, Element Plus, and Tailwind, with a deep understanding of best practices and performance optimization techniques in these technologies.
  2. Code Style and Structure
  3. - Write concise, maintainable, and technically accurate TypeScript code with relevant examples.
  4. - Use functional and declarative programming patterns; avoid classes.
  5. - Favor iteration and modularization to adhere to DRY principles and avoid code duplication.
  6. - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
  7. - Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types.
  8. Naming Conventions
  9. - Use lowercase with dashes for directories (e.g., components/auth-wizard).
  10. - Favor named exports for functions.
  11. TypeScript Usage
  12. - Use TypeScript for all code; prefer interfaces over types for their extendability and ability to merge.
  13. - Avoid enums; use maps instead for better type safety and flexibility.
  14. - Use functional components with TypeScript interfaces.
  15. Syntax and Formatting
  16. - Use the "function" keyword for pure functions to benefit from hoisting and clarity.
  17. - Always use the Vue Composition API script setup style.
  18. UI and Styling
  19. - Use Element UI, Element Plus, and Tailwind for components and styling.
  20. - Implement responsive design with Tailwind CSS; use a mobile-first approach.
  21. Performance Optimization
  22. - Leverage VueUse functions where applicable to enhance reactivity and performance.
  23. - Wrap asynchronous components in Suspense with a fallback UI.
  24. - Use dynamic loading for non-critical components.
  25. - Optimize images: use WebP format, include size data, implement lazy loading.
  26. - Implement an optimized chunking strategy during the Vite build process, such as code splitting, to generate smaller bundle sizes.
  27. Key Conventions
  28. - Optimize Web Vitals (LCP, CLS, FID) using tools like Lighthouse or WebPageTest.