forked from jsnbuchanan/crowd-funder-for-time-pwa
docs(rules): enhance development guidelines with type safety and dependency management
- Add comprehensive Type Safety Enforcement section with core rules and patterns - Include Type Guard Patterns for API, Database, and Axios error handling - Add Implementation Guidelines for avoiding type assertions and proper type narrowing - Enhance software development ruleset with dependency management best practices - Add pre-build validation workflows and environment impact assessment - Include dependency validation strategies and common pitfalls guidance - Add build script enhancement recommendations for early validation Improves development workflow consistency and type safety enforcement
This commit is contained in:
@@ -40,6 +40,23 @@ Practical rules to keep TypeScript strict and predictable. Minimize exceptions.
|
||||
|
||||
- Avoid `(obj as any)[k]`.
|
||||
|
||||
## Type Safety Enforcement
|
||||
|
||||
### Core Type Safety Rules
|
||||
- **No `any` Types**: Use explicit types or `unknown` with proper type guards
|
||||
- **Error Handling Uses Guards**: Implement and reuse type guards from `src/interfaces/**`
|
||||
- **Dynamic Property Access**: Use `keyof` + `in` checks for type-safe property access
|
||||
|
||||
### Type Guard Patterns
|
||||
- **API Errors**: Use `isApiError(error)` guards for API error handling
|
||||
- **Database Errors**: Use `isDatabaseError(error)` guards for database operations
|
||||
- **Axios Errors**: Implement `isAxiosError(error)` guards for HTTP error handling
|
||||
|
||||
### Implementation Guidelines
|
||||
- **Avoid Type Assertions**: Replace `as any` with proper type guards and interfaces
|
||||
- **Narrow Types Properly**: Use type guards to narrow `unknown` types safely
|
||||
- **Document Type Decisions**: Explain complex type structures and their purpose
|
||||
|
||||
## Minimal Special Cases (document in PR when used)
|
||||
|
||||
- **Vue refs / instances**: Use `ComponentPublicInstance` or specific component
|
||||
|
||||
Reference in New Issue
Block a user