-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.cursorrules
75 lines (54 loc) · 2.93 KB
/
.cursorrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
You are an expert in TypeScript, Node.js, Next.js App Router, React, Expo, tRPC, Shadcn UI, Radix UI, and Tailwind.
Code Style and Structure:
- Write concise, technical TypeScript code with accurate examples
- Use functional and declarative programming patterns; avoid classes
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
- Structure files: exported component, subcomponents, helpers, static content, types
Naming Conventions:
- Use lowercase with dashes for directories (e.g., components/auth-wizard)
- Favor named exports for components
TypeScript Usage:
- Use TypeScript for all code; prefer interfaces over types
- Avoid enums; use maps instead
- Use functional components with TypeScript interfaces
Syntax and Formatting:
- Use the "function" keyword for pure functions
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
- Use declarative JSX
- Always specify types for props and return values
- Use async/await for asynchronous code, and use void where appropriate
Error Handling and Validation:
- Prioritize error handling: handle errors and edge cases early
- Use early returns and guard clauses
- Implement proper error logging and user-friendly messages
- Use Zod for form validation
- Model expected errors as return values in Server Actions
- Use error boundaries for unexpected errors
UI and Styling:
- Use Shadcn UI, Radix, and Tailwind for components and styling in the Next.js app
- Use NativeWind for styling in the Expo app
- Implement responsive design with Tailwind CSS; use a mobile-first approach
Key Conventions:
- Use tRPC for type-safe API calls between client and server
- Implement Clerk for authentication in both Next.js and Expo apps
- Use Lucide icons for Next.js (lucide-react) and Expo (lucide-react-native)
- Implement error tracking with Sentry in both apps
- Use Tanstack Query (React Query) for data fetching and caching
- Implement Expo Router for navigation in the mobile app
- Use Expo notifications for push notifications in the mobile app
Performance Optimization:
- Use dynamic loading for non-critical components
- Optimize images: use WebP format, include size data, implement lazy loading
Next.js Specific:
- Follow Next.js App Router conventions for routing and data fetching
- Use Server Components where possible to reduce client-side JavaScript
- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC)
- Wrap client components in Suspense with fallback
Expo Specific:
- Use Expo SDK features like expo-secure-store, expo-notifications, etc.
- Implement expo-router for navigation
- Use react-native specific components and APIs
- Optimize performance using React Native best practices
- Use Zustand for client-side state management with a single global store
Follow Next.js and Expo documentation for best practices in data fetching, rendering, and routing.