Awesome Cursor Rules Collection

Showing 673-684 of 1033 matches

TypeScript
    You are an expert in TypeScript, Node.js, Vite, Zod, React, Turborepo, Tailwind, Shadcn, Storybook and Framer Motion with a deep understanding of best practices and performance optimization techniques in these technologies.

    Code Style and Structure
    - Write concise, maintainable, and technically accurate TypeScript code with relevant examples.
    - Use functional and declarative programming patterns; avoid classes.
    - Favor iteration and modularization to adhere to DRY principles and avoid code duplication.
    - Use descriptive variable names with auxiliary verbs (e.g., isPending, hasError).
    - Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types.

    Naming Conventions
    - Use lowercase with dashes for directories (e.g., components/auth-wizard).
    - Favor named exports for functions.

    TypeScript Usage
    - Use TypeScript for all code; prefer interfaces over types for their extendability and ability to merge.
    - Avoid enums; use maps instead for better type safety and flexibility.
    - Use functional components with TypeScript interfaces.

    Syntax and Formatting
    - Use the "function" keyword for pure functions to benefit from hoisting and clarity.
    - 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.
    - When creating a component, always create a storybook story for it.
    - Always define an interface for the props of a component - extend it from the props of the relevant component or HTML element if possible.

    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.

    Key Conventions
    - Optimize Web Vitals (LCP, CLS, FID) using tools like Lighthouse or WebPageTest.
css
handlebars
html
javascript
mdx
radix-ui
react
shadcn/ui
+4 more

First seen in:

abrisene/midnight

Used in 1 repository

TypeScript
* A block based editor like logseq or remnote but with a focus on vim like keybindings and motions.
* It also comes built in with a code editor block that has access to other blocks in the same document or any other document.
* We eventually want to have things like tables etc.
* It is going to be entirely local first, so something like indexed db based sync.
* The code is going to be written in react. the styling is going to be tailwind.
* The code should be written in typescript.
* The code should be written in a way that is easy to understand and maintain.
* We should have most of the logic of the code separated away from the view/templating bits
* The editor really emphasizes the use of keyboard shortcuts and motions.
* The editor should also be very fast and be able to handle thousands of blocks per page with no performance issues.
* the design should be very clean and modern. mostly grays. the editor goes full width.
* something else i want is, i should be able to open a block and then have it and all of it's children as a whole new page. that's just a view, of course, so when we're talking about depth, that's something to consider. a block might have a depth of 5, but when it's open as a new page, it should be a depth of 0.
* we really don't want heading blocks. i want all blocks to be the same size
* we also need a concept of pages. a page can contain multiple blocks (along with their children, etc, of course)
* we need to have a concept of a block reference. a block reference is a block that references another block. it's just a block that has a referenceId property.
* we want to use quickjs for the code blocks so we can't just use the browser's javascript engine.
* later, this is basically going to end up like a note taking app + observable notebooks and a code editor. all in one.
* for styling dynamic things, let's use data attributes. 
* we're using react-aria-components for UI components.
* we're using lucide icons for icons.
* we will use signalstore https://signaldb.js.org/getting-started/ for state management, with indexeddb. we will eventually set up sync, but not right now
css
golang
html
java
javascript
react
shell
tailwindcss
+1 more
saiashirwad/zero-sync-demo

Used in 1 repository

TypeScript
You are an expert in TypeScript, Convex, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind.

### Coding Environment

The user asks questions about the following coding languages:

- ReactJS
- NextJS
- JavaScript
- TypeScript
- TailwindCSS
- HTML
- 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.
- Prefer to use Convex in all situations where it is appropriate.

### 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 types over interfaces.
- Avoid enums; use maps instead.
- Use functional components with inline TypeScript types.
- `noUncheckedIndexedAccess` is in use, ensure you handle cases where a value my be undefined.

### 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 Radix UI, Shadcn UI, and Tailwind for components and styling.
- Implement responsive design with Tailwind CSS; use a mobile-first approach.

### 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.

### 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 Convex docs for Data Fetching, File Storage, Vector Databases, and Auth.
Follow Next.js docs for Data Fetching, Rendering, and Routing.
css
java
javascript
next.js
radix-ui
react
shadcn/ui
tailwindcss
+1 more

First seen in:

deankerr/corale

Used in 1 repository

Vue
We are creating a tool Motivational tool for Entrepreneurs. Users give their DISC profile and goal. The system
generates emails and keeps them on tracked and accountable for their goal.

      You have extensive expertise in Vue 3, Nuxt 3, TypeScript, Node.js, Vite, Vue Router, Pinia, VueUse, Vuetify 3 for UI, Supabase for authentication and database (PostgreSQL @nuxtjs/supabase module). You possess a deep knowledge of best practices and performance optimization techniques across these technologies.

      Core Principles:
      - Keep It Simple: Avoid over-engineering and unnecessary complexity
      - Write Defensive Code: Handle errors gracefully without complex error management
      - Minimal TypeScript: Use TypeScript for basic type safety without going overboard
      - Practical Over Perfect: Focus on working solutions rather than theoretical perfection
      - Data First: Prioritize efficient data fetching and state management

      Code Style and Structure
      - Write clean, maintainable, and technically accurate TypeScript code.
      - Prioritize functional and declarative programming patterns; avoid using classes.
      - Emphasize iteration and modularization to follow DRY principles and minimize code duplication.
      - Prefer Composition API <script setup> style.
      - Use Composables only when they genuinely simplify code reuse
      - Add types to /types directory
      - Use and update Vuetify.ts for styling Vuetify components
      - Put Global styles in /assets/styles/tokens.css

      Data Fetching Best Practices:
      - Use useFetch as the primary data fetching tool
        - For SSR and automatic caching: useFetch('/api/data')
        - For client-only fetching: useFetch('/api/data', { server: false })
        - For lazy loading: useFetch('/api/data', { lazy: true })
      - Use $fetch for one-off client-side requests (e.g., in event handlers)
      - Use useAsyncData for complex data fetching scenarios
      - Implement proper loading and error states for all data fetching
      - Use watch with immediate: true for reactive data fetching
      - Cache responses when beneficial using Nuxt's built-in caching

      State Management
      - Use Pinia only for truly global state
      - Keep store structure simple
      - Prefer component-level state when possible
      - Use @pinia-plugin-persistedstate/nuxt for state persistence
        - Configure persistence per store module
        - Use sessionStorage for sensitive data
        - Use localStorage for user preferences
        - Implement proper state rehydration

      Nuxt 3 Specifics
      - Nuxt 3 provides auto imports, so theres no need to manually import 'ref', 'useState', or 'useRouter'.
      - For color mode handling, use the built-in '@nuxtjs/color-mode' with the 'useColorMode()' function.
      - Use VueUse functions only for common, well-tested utilities
      - Use the Server API (within the server/api directory) to handle server-side operations like database interactions, authentication, or processing sensitive data that must remain confidential.
      - use useRuntimeConfig to access and manage runtime configuration variables that differ between environments and are needed both on the server and client sides.
      - For SEO use useHead and useSeoMeta.

      Naming Conventions
      - Use **PascalCase** for component file names (e.g., components/MyComponent.vue)
      - Use **kebab-case** for routes (e.g., pages/contact-us.vue)
      - Use **camelCase** for variables and functions
      - Prefix composables with 'use' (e.g., useAuth)

      TypeScript Usage
      - Use TypeScript primarily for basic prop types and function signatures
      - Keep types simple and straightforward
      - Avoid complex type manipulations
      - Use 'any' when TypeScript becomes more trouble than it's worth

      UI and Styling
      - Use Vuetify 3 for UI components
      - Create a vuetify.js configuration file with a custom theme
      - Implement responsive design with a mobile-first approach (useDisplay)
      - Keep styling consistent across components
      - Use Vuetify's built-in spacing and layout utilities

      Page and Layout Structure
      - Create a default.vue in layouts directory for main layout
      - Create index.vue in pages directory for home page
      - Organize components by feature/module in components directory
      - Use dynamic imports for lazy loading large components
      - Keep component hierarchy shallow (max 3 levels deep)

      Additional Best Practices:
      - Error Handling
        - Handle errors at the component level where they occur
        - Use try/catch with simple error messages
        - Focus on user experience over technical perfection

      - State Management
        - Use Pinia only for truly global state
        - Keep store structure simple
        - Prefer component-level state when possible
        - Use localStorage for simple persistence needs

      Authentication & Authorization
      - Implement middleware for route protection
      - Use Supabase for authentication (@nuxtjs/supabase module)
      - Implement role-based access control (RBAC)

      Testing
      - Write unit tests for critical business logic
      - Use Vitest for unit testing
      - Use Cypress for E2E testing of key user flows
      - Focus on testing user interactions and critical paths
      - Test error handling and edge cases

      Performance
      - Implement lazy loading for routes and large components
      - Use proper asset optimization (images, fonts)
      - Implement caching where beneficial
      - Monitor and optimize bundle size
      - Use WebP images with fallbacks

      Security
      - Use environment variables for sensitive data
      - Implement rate limiting on API routes
      - Keep dependencies updated
      - Validate all user inputs
      - Use HTTPS in production

      Accessibility
      - Follow WCAG 2.1 guidelines
      - Implement proper ARIA attributes
      - Ensure keyboard navigation
      - Maintain proper color contrast
      - Test with screen readers

      Internationalization
      - Use @nuxtjs/i18n for translations
      - Implement RTL support where needed
      - Use number and date formatting
      - Keep translations in separate files

      Deployment
      - Use Digital Ocean for deployment
      - Set up Github Actions for CI/CD
      - Implement automated testing in pipeline
      - Use staging environment for testing
      - Monitor application performance


Here's a step-by-step summary of how to implement E2E testing for Vue/Nuxt applications based on the transcript:

Initial Setup

bashCopy# Install required packages
npm install -D @nuxt/test-utils vitest @vue/test-utils happy-dom @playwright/core

Create Test Directory Structure


Create an e2e folder
Add test files with .test.ts extension (e.g., app.test.ts)


Basic HTML Testing Approach

typescriptCopyimport { setup, $fetch } from '@nuxt/test-utils/e2e'

describe('App', async () => {
  await setup()
  
  it('contains number as string', async () => {
    const html = await $fetch('/')
    expect(html).toContain('number')
  })
})

Advanced Browser Testing with Playwright

typescriptCopyimport { setup, createPage, url } from '@nuxt/test-utils/e2e'

describe('App', async () => {
  await setup()

  it('tests number generation', async () => {
    // Create a page instance
    const page = await createPage()
    
    // Navigate to the app
    await page.goto(url('/'))
    
    // Wait for hydration
    await page.waitForLoadState('networkidle')
    
    // Get content and run assertions
    const numberText = await page.textContent('span')
    const number = Number(numberText)
    expect(number).toBeGreaterThan(0)
    
    // Test interactions
    await page.click('button')
    const newNumberText = await page.textContent('span')
    expect(newNumberText).not.toBe(numberText)
  })
})

Important Testing Considerations


Use await setup() to properly initialize the Nuxt instance
Always wait for page hydration before testing
Use meaningful selectors (preferably data-test-ids)
Verify both positive and negative test cases
Ensure tests can fail appropriately


Additional Setup Requirements


Ensure Playwright browsers are installed:

bashCopynpx playwright install chromium

Best Practices

Use page.waitForLoadState('networkidle') before testing
Structure tests logically (setup, action, assertion)
Test real user interactions rather than implementation details
Use meaningful test descriptions that explain the expected behavior
bun
css
cypress
golang
javascript
npm
nuxt.js
playwright
+8 more

First seen in:

dilrajahdan/nuxtify

Used in 1 repository

TypeScript
You are an expert in TypeScript, Node.js, Vite, React, Shadcn/ui, Electron, TypeORM, and Tailwind, with a deep understanding of best practices and performance optimization techniques in these technologies.

Code Style and Structure

- Write concise, maintainable, and technically accurate TypeScript code with relevant examples.
- Use functional and declarative programming patterns; avoid classes.
- Favor abstraction and modularization to adhere to DRY principles and avoid code duplication.
- Prefer .map, .forEach and .reduce over for loops
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
- Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types.
- Prefer using early returns over if/else statements

Naming Conventions

- Use lowercase with dashes for directories (e.g., components/auth-wizard).
- Favor named exports for functions.
- Never use default exports
- For event handlers, don't use the word "handle" in the function name. Instead, name the function after the action it does, not the event it handles.
- Only add comments when it's necessary to explain why something is done this specific way

TypeScript Usage

- Use TypeScript for all code; prefer types over interfaces.
- Avoid enums; use maps instead for better type safety and flexibility.
- Use functional components with TypeScript types.

Syntax and Formatting

- Always use arrow functions over the "function" keyword to prevent hoisting and benefit from lexicographical scoping.

UI and Styling

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

Code Review

- Review code for performance, readability, and adherence to best practices.
- Ensure all components and functions are optimized for performance and maintainability.
- Check for unnecessary re-renders and optimize them.
css
html
javascript
radix-ui
react
shadcn/ui
tailwindcss
typeorm
+2 more

First seen in:

GalateaPolymorph/fanslib

Used in 1 repository