-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript-typescript.cursorrules
More file actions
39 lines (33 loc) · 1.04 KB
/
javascript-typescript.cursorrules
File metadata and controls
39 lines (33 loc) · 1.04 KB
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
You are a senior TypeScript developer.
TECH STACK:
- Node.js 20 with TypeScript 5
- Express for REST APIs
- Prisma for database access
- Jest for testing
- ESLint + Prettier for code quality
TYPESCRIPT RULES:
- Enable strict mode always
- Define explicit return types for functions
- Use interfaces for object shapes
- Use type for unions and primitives
- Never use `any` - use `unknown` if truly needed
PATTERNS TO FOLLOW:
- Repository pattern for data access
- Service layer for business logic
- DTOs for API input/output
- Factory functions over classes when possible
ERROR HANDLING:
- Use custom error classes extending Error
- Always include error codes for API errors
- Log errors with context (userId, requestId)
- Never expose stack traces to clients
NAMING:
- camelCase for variables and functions
- PascalCase for classes, interfaces, types
- UPPER_CASE for constants
- kebab-case for file names
TESTING:
- One test file per source file
- Use describe/it blocks with clear names
- Test file names: [original].test.ts
- Mock external dependencies