jordiparadelo Japp-Media .cursorrules file for TypeScript

You must rewrite the file according to the user's instructions

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

UI and Styling
- Use style modules with sass to stylize components (e.g Button.module.scss), use tailwind for global styles.
- Implement responsive design; use a mobile-first approach.
- Use framer motion and gsap for animations always try to be performant and efficient.

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.

Folder Structure
- components: ui, layout, booking, etc; ui and sections have an entry point index.ts file that exports the component.
- app: (pages, api, layout, loading, not-found, etc)
- src: (assets, components, app, hooks, constants, lib, styles, types, utils, validations, etc)

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.

Follow Next.js docs for Data Fetching, Rendering, and Routing.

React SOLID Principles and Best Practices
- Single Responsibility Principle (SRP):
  - Create focused components with a single purpose.
  - Extract complex logic into custom hooks (e.g., useDataFetching, useFormValidation).
  - Separate UI rendering from business logic.

- Open-Closed Principle (OCP):
  - Design components to be easily extendable without modifying existing code.
  - Use composition and higher-order components for reusability.

- Liskov Substitution Principle (LSP):
  - Ensure child components can replace parent components without breaking the application.
  - Use TypeScript to enforce proper prop types and interfaces.

- Interface Segregation Principle (ISP):
  - Create small, specific interfaces rather than large, general ones.
  - Use TypeScript to define clear prop interfaces for components.

- Dependency Inversion Principle (DIP):
  - Depend on abstractions, not concretions.
  - Use dependency injection to provide services to components.

Custom Hooks Best Practices
- Create custom hooks to encapsulate and reuse stateful logic.
- Name custom hooks with the 'use' prefix (e.g., useAuth, useCart).
- Keep hooks focused on a single concern or feature.
- Use TypeScript to define clear return types for custom hooks.

Component Structure
- Separate presentational and container components when appropriate.
- Use custom hooks to manage component logic and state.
- Keep components small and focused on a single responsibility.
- Extract reusable logic into utility functions or custom hooks.
css
javascript
next.js
react
sass
scss
solidjs
tailwindcss
+1 more

First Time Repository

Website de servicios

TypeScript

Languages:

CSS: 7.1KB
JavaScript: 0.3KB
SCSS: 25.7KB
TypeScript: 117.9KB
Created: 9/14/2024
Updated: 11/13/2024

All Repositories (1)

Website de servicios