Platform: Crystal Comics (
crystal-scans)
Repository Root:D:\Projects\Crystal-Comics
Scope: Front-end React code, TypeScript typing, Tailwind CSS styling, Supabase services, and Discord integration scripts.
- NO Direct Mutation of React / LocalStorage State:
- β Never do
user.bookmarks.push(id)without updating state through setter functions or copying objects ([...user.bookmarks, id]).
- β Never do
- NO Unchecked Null/Undefined Object Dereferencing:
- β Never call
user.discord.iddirectly without safe navigation or fallback optional chaining (user?.discord?.id).
- β Never call
- NO Hardcoded Pixel Container Offsets for Dynamic Elements:
- β Avoid
height: calc(100vh - 147px). Use flexbox (flex-grow,min-h-screen) or grid layout containers.
- β Avoid
- NO Silent Promise Failure Rejections:
- β Never catch errors silently with an empty
catch {}block. Always log errors or provide meaningful UI error states.
- β Never catch errors silently with an empty
- NO Wildcard Unscoped CSS Overrides:
- β Avoid modifying global HTML elements directly inside component files. Keep component styles scoped via Tailwind CSS utility classes.
- Explicit Return Types: All async service functions in
services/must have explicit return types (e.g.Promise<Manga[]>,Promise<boolean>). - No Implicit
any: Always define proper interfaces in types.ts or extend existing ones. - Strict Optional Handling: Mark optional properties with
?(e.g.,heroUrl?: string).
- Functional Components: Use
React.FC<Props>signature for components. - Effect Cleanup: Always return cleanup functions in
useEffectwhen subscribing to listeners (e.g.subscription.unsubscribe()inonAuthStateChange). - Route Scroll Reset: Ensure all pages rendered inside
Routesbenefit from the<ScrollToTop />component.
- Dark Mode Design System: Use curated dark tokens (
bg-[#050508],bg-[#0E0E15],text-purple-400,text-cyan-400). - Glassmorphism: Use backdrop filters for overlays:
backdrop-blur-md bg-[#0E0E15]/80 border border-white/10. - Interactive Feedback: All clickable cards, buttons, and icons MUST include visible hover states (
hover:text-purple-400,hover:scale-105 transition-all).
- Environment Key Safety: Never hardcode Supabase project secrets or Discord Bot tokens in frontend files. Use
import.meta.env.VITE_SUPABASE_URLandimport.meta.env.VITE_SUPABASE_ANON_KEY. - Fallback Verification: Always handle cases where
supabaseclient isnull(e.g. when env vars are unconfigured in local dev mode).
Before declaring any feature complete:
- Run
npm run buildto verify there are zero TypeScript compilation errors. - Test responsive layouts at mobile (
375px), tablet (768px), and desktop (1440px) viewport widths. - Test bookmarking, reading history tracking, and comment creation locally to confirm LocalStorage state persistence.