Dark-Developer93 LeaveTracker .cursorrules file for TypeScript

You are an expert in TypeScript, Node.js, Next.js 14 App Router, React, NextAuth, Prisma ORM, Postgress, react-email library, TanStack React Query, Zod, Shadcn UI, and Tailwind CSS.

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 "arrow function" keyword for pure functions.
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
- Use declarative JSX.

UI and Styling

- Use Shadcn UI, Radix, and Tailwind for components and styling.
- Implement responsive design with Tailwind CSS; use a mobile-first approach.

Error Handling and Validation

- Prioritize error handling and edge cases:
- Use early returns for error conditions.
- Implement guard clauses to handle preconditions and invalid states early.
- Use custom error types for consistent error handling.

State Management and datafetching

- Use modern state management solutions (TanStack React Query) to handle global state and data fetching.
- Implement validation using Zod for schema validation.

Performance Optimization

- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC).
- Wrap client components in Suspense with fallback.
- Use dynamic loading for non-critical components.
- Optimize images: use WebP format, include size data, implement lazy loading.

Security and Performance

- Implement proper error handling, user input validation, and secure coding practices.
- Follow performance optimization techniques, such as reducing load times and improving rendering efficiency.

Key Conventions

- Use 'nuqs' for URL search parameter state management.
- Optimize Web Vitals (LCP, CLS, FID).
- Limit 'use client':
  - Favor server components and Next.js SSR.
  - Use only for Web API access in small components.
  - Avoid for data fetching or state management.

Methodology 1. System 2 Thinking: Approach the problem with analytical rigor. Break down the requirements into smaller, manageable parts and thoroughly consider each step before implementation. 2. Tree of Thoughts: Evaluate multiple possible solutions and their consequences. Use a structured approach to explore different paths and select the optimal one. 3. Iterative Refinement: Before finalizing the code, consider improvements, edge cases, and optimizations. Iterate through potential enhancements to ensure the final solution is robust.

Process: 1. Deep Dive Analysis: Begin by conducting a thorough analysis of the task at hand, considering the technical requirements and constraints. 2. Planning: Develop a clear plan that outlines the architectural structure and flow of the solution, using <PLANNING> tags if necessary. 3. Implementation: Implement the solution step-by-step, ensuring that each part adheres to the specified best practices. 4. Review and Optimize: Perform a review of the code, looking for areas of potential optimization and improvement. 5. Finalization: Finalize the code by ensuring it meets all requirements, is secure, and is performant.

Follow Next.js docs for Data Fetching, Rendering, and Routing.
css
golang
javascript
next.js
nextauth
postgresql
prisma
radix-ui
+4 more

First Time Repository

TypeScript

Languages:

CSS: 1.9KB
JavaScript: 2.3KB
TypeScript: 231.4KB
Created: 2/12/2024
Updated: 11/24/2024

All Repositories (1)