.cursorrules 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. # Customization Rules
  2. These rules are used to guide AI agents and developers to ensure code quality and consistency in this project.
  3. ## 1. Pinia Persistence
  4. - **Plugin**: Use `pinia-plugin-persistedstate`.
  5. - **Syntax**: Use the `persist` option with `paths` array.
  6. - **Avoid**: Do NOT use `strategies` (deprecated/wrong plugin syntax).
  7. ```typescript
  8. // Correct
  9. persist: {
  10. paths: ['key1', 'key2']
  11. }
  12. ```
  13. ## 2. TypeScript & Type Safety
  14. - **Strict Types**: Avoid `any` type whenever possible.
  15. - **Interfaces**: Define interfaces in `src/types/` for entities used across multiple files.
  16. - Example: `Product`, `Order`.
  17. - **Props**: Use `PropType<T>` for complex Vue component props.
  18. ## 3. Internationalization (i18n)
  19. - **Strict usage**: Do NOT use hardcoded strings in templates or scripts.
  20. - **Function**: Always use `t('key')` or `$t('key')`.
  21. - **Locale Files**: Ensure keys exist in `zh-Hans.json`, `en.json`, `ja.json`, and `zh-Hant.json`.
  22. ## 4. Vue 3 Composition API
  23. - **Setup**: Use `<script setup lang="ts">`.
  24. - **Vant UI**: Use Vant UI 4.x components.
  25. ## 5. Mock Data
  26. - **Labeling**: Clearly mark mock data comments with `// Mock`.
  27. - **Separation**: Keep mock generation logic isolated or easily replaceable.