diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 6073df23..2a303cfe 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -40,9 +40,30 @@ and provides seamless media streaming with offline capabilities and Chromecast s - `scripts/` – Automation scripts (Node.js, Bash) - `plugins/` – Expo/Metro plugins -## Coding Standards +## Code Quality Standards +**CRITICAL: Code must be production-ready, reliable, and maintainable** + +### Type Safety - Use TypeScript for ALL files (no .js files) +- **NEVER use `any` type** - use proper types, generics, or `unknown` with type guards +- Use `@ts-expect-error` with detailed comments only when necessary (e.g., library limitations) +- When facing type issues, create proper type definitions and helper functions instead of using `any` +- Use type assertions (`as`) only as a last resort with clear documentation explaining why +- For Expo Router navigation: prefer string URLs with `URLSearchParams` over object syntax to avoid type conflicts +- Enable and respect strict TypeScript compiler options +- Define explicit return types for functions +- Use discriminated unions for complex state + +### Code Reliability +- Implement comprehensive error handling with try-catch blocks +- Validate all external inputs (API responses, user input, query params) +- Handle edge cases explicitly (empty arrays, null, undefined) +- Use optional chaining (`?.`) and nullish coalescing (`??`) appropriately +- Add runtime checks for critical operations +- Implement proper loading and error states in components + +### Best Practices - Use descriptive English names for variables, functions, and components - Prefer functional React components with hooks - Use Jotai atoms for global state management @@ -50,8 +71,10 @@ and provides seamless media streaming with offline capabilities and Chromecast s - Follow BiomeJS formatting and linting rules - Use `const` over `let`, avoid `var` entirely - Implement proper error boundaries -- Use React.memo() for performance optimization +- Use React.memo() for performance optimization when needed - Handle both mobile and TV navigation patterns +- Write self-documenting code with clear intent +- Add comments only when code complexity requires explanation ## API Integration diff --git a/components/common/SeerrItemRouter.tsx b/components/common/SeerrItemRouter.tsx index 184ef490..c6ab28fd 100644 --- a/components/common/SeerrItemRouter.tsx +++ b/components/common/SeerrItemRouter.tsx @@ -42,18 +42,24 @@ export const TouchableSeerrRouter: React.FC> = ({ onPress={() => { if (!result) return; - router.push({ - pathname: `/(auth)/(tabs)/${from}/seerr/page`, - // @ts-expect-error - params: { - ...result, - mediaTitle, - releaseYear, - canRequest: canRequest.toString(), - posterSrc, - mediaType, - }, + // Build URL with query params - avoids Expo Router's strict type checking + const params = new URLSearchParams({ + ...Object.fromEntries( + Object.entries(result).map(([key, value]) => [ + key, + String(value ?? ""), + ]), + ), + mediaTitle, + releaseYear: releaseYear.toString(), + canRequest: canRequest.toString(), + posterSrc, + mediaType: mediaType.toString(), }); + + router.push( + `/(auth)/(tabs)/(home,libraries,search,favorites,watchlists)/seerr/page?${params.toString()}`, + ); }} {...props} > diff --git a/components/seerr/Cast.tsx b/components/seerr/Cast.tsx index 0af02433..e4b805b0 100644 --- a/components/seerr/Cast.tsx +++ b/components/seerr/Cast.tsx @@ -20,7 +20,6 @@ const CastSlide: React.FC< horizontal showsHorizontalScrollIndicator={false} data={details?.credits.cast} - estimatedItemSize={112} ItemSeparatorComponent={() => } keyExtractor={(item) => item?.id?.toString() ?? ""} contentContainerStyle={{ paddingHorizontal: 16 }} diff --git a/components/seerr/ParallaxSlideShow.tsx b/components/seerr/ParallaxSlideShow.tsx index 261da73d..57b81a0b 100644 --- a/components/seerr/ParallaxSlideShow.tsx +++ b/components/seerr/ParallaxSlideShow.tsx @@ -133,7 +133,7 @@ const ParallaxSlideShow = ({ {Array.from({ length: 9 }, (_, i) => ( - + ))} diff --git a/components/seerr/discover/Slide.tsx b/components/seerr/discover/Slide.tsx index 7f794a3c..adbe2f81 100644 --- a/components/seerr/discover/Slide.tsx +++ b/components/seerr/discover/Slide.tsx @@ -44,7 +44,6 @@ const Slide = ({ data={data} onEndReachedThreshold={1} onEndReached={onEndReached} - //@ts-expect-error renderItem={({ item, index }) => item ? renderItem(item, index) : null }