agentleFS
robotostudiorobotostudio/turbo-start-sanity/.cursor/rules/ultracite-migration.mdc

turbo-start-sanity / rules

Cursor rule185 starsChanged 2 months agoMITView on GitHub

Guide for migrating from ESLint/Prettier to Ultracite

  • Installs packages

We split this ultracite-migration.mdc into the rules it gives an agent

13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Delete entire packages/eslint-config/ directory

    line 125
  2. Very specific:

    Important: If you have redirects from Sanity, ensure they handle null values:

    line 140
  3. Distinctive:

    Verify both studio and web start correctly.

    line 256
  4. Distinctive:

    No double-formatting or jerking

    line 265
  5. Distinctive:

    No ESLint/Prettier errors in problems panel

    line 266
  6. Very specific:

    Use npx ultracite fix instead of prettier --write (formats + fixes + organizes imports)

    line 270
  7. Very specific:

    Use npx ultracite lint instead of eslint

    line 271
  8. Distinctive:

    Import sorting is built-in, no extra plugins needed

    line 274
  9. Very specific:

    Ensure formatOnSave: false in .vscode/settings.json

    line 281
  10. Distinctive:

    Check your user settings don't have conflicting formatter settings

    line 282
  11. Very specific:

    Only use codeActionsOnSave with Biome actions

    line 283
  12. Distinctive:

    Fix: Add explicit type annotations:

    line 291
  13. Very specific:

    Fix: Add error handling in generateStaticParams:

    line 299

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
ultracite-migration.mdc
---
description: Guide for migrating from ESLint/Prettier to Ultracite
alwaysApply: false
---

# Ultracite Migration Guide

Quick reference for migrating Turbostart monorepo projects from ESLint/Prettier to Ultracite (Biome preset).

**Project Structure Assumed:**
```
/
├── apps/
│   ├── studio/      # Sanity CMS
│   └── web/         # Next.js app
├── packages/
│   ├── eslint-config/  # To be deleted
│   └── ui/             # Shared components
├── turbo.json
└── package.json
```

## 1. Install Dependencies

```bash
pnpm add -D -w ultracite @biomejs/biome@latest
```

## 2. Create Root Configuration

Create `biome.jsonc`:

```json
{
  "$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
  "extends": ["ultracite"]
}
```

## 3. Configure Cursor

Create/update `.vscode/settings.json`:

```json
{
  "editor.defaultFormatter": "biomejs.biome",
  "editor.formatOnSave": false,
  "editor.formatOnPaste": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[json]": {
    "editor.defaultFormatter": "biomejs.biome"
  }
}
```

**Important:** Set `formatOnSave: false` and use `codeActionsOnSave` to prevent double-formatting issues.

## 4. Update All package.json Scripts

Replace in root and all workspace packages:

```json
{
  "scripts": {
    "lint": "npx ultracite lint",
    "format": "npx ultracite fix"
  }
}
```

## 5. Remove Old Dependencies & Configs

### Root (`package.json`)
Remove from `devDependencies`:
- `@workspace/eslint-config`
- `prettier`

### `apps/studio/package.json`
Remove from `devDependencies`:
- `eslint`
- `eslint-plugin-import`
- `eslint-plugin-prettier`
- `eslint-plugin-simple-import-sort`
- `prettier`
- `typescript-eslint`

Delete files:
- `apps/studio/eslint.config.mjs`
- `apps/studio/prettier.config.mjs`

### `apps/web/package.json`
Remove from `devDependencies`:
- `@workspace/eslint-config`
- `prettier`

Delete files:
- `apps/web/eslint.config.js`
- `apps/web/prettier.config.mjs`
- `apps/web/.prettierignore` (if exists)

### `packages/ui/package.json`
Remove from `devDependencies`:
- `@workspace/eslint-config`
- `eslint`

Delete files:
- `packages/ui/eslint.config.js`

### Delete Entire Package
- Delete entire `packages/eslint-config/` directory

## 6. Update Next.js Config

In `apps/web/next.config.ts`, disable ESLint during builds:

```typescript
export default {
  eslint: {
    ignoreDuringBuilds: true,
  },
  // ... rest of config
}
```

**Important:** If you have redirects from Sanity, ensure they handle `null` values:

```typescript
async redirects() {
  const redirects = await client.fetch(queryRedirects);
  return redirects.map((redirect) => ({
    ...redirect,
    permanent: redirect.permanent ?? false,
  }));
}
```

## 7. Update Turborepo Config

In `turbo.json`:

```json
{
  "tasks": {
    "//#format": {},
    "//#lint": {
      "cache": false
    }
  }
}
```

## 8. Common Rule Adjustments

### For Tailwind CSS (apps/web uses this)
Add to `biome.jsonc`:

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noUnknownAtRules": "off",
        "noExplicitAny": "warn"
      }
    }
  }
}
```

### If you encounter namespace import issues
```json
{
  "linter": {
    "rules": {
      "performance": {
        "noNamespaceImport": "off"
      }
    }
  }
}
```

## 9. Testing Checklist

### Step 1: Install & Format
```bash
# Install dependencies
pnpm install

# Format all code (from root)
pnpm format

# Review the changes - should reorganize imports and format code
git diff
```

### Step 2: Lint
```bash
# Run linter (from root)
pnpm lint

# Fix any auto-fixable issues
pnpm format
```

### Step 3: Build All Packages
```bash
# From root - build everything
pnpm build
```

Should successfully build:
- `apps/studio` (Sanity Studio)
- `apps/web` (Next.js)
- `packages/ui`

### Step 4: Test Individual Packages
```bash
# Test studio
cd apps/studio
pnpm lint
pnpm format

# Test web
cd apps/web
pnpm lint
pnpm format

# Test ui
cd packages/ui
pnpm lint
pnpm format
```

### Step 5: Test Dev Servers
```bash
# From root
pnpm dev
```

Verify both studio and web start correctly.

### Step 6: Restart Cursor & Test Editor
1. Restart Cursor: `Cmd/Ctrl + Shift + P` → "Developer: Reload Window"
2. Open a `.ts` or `.tsx` file
3. Make a change and hit `Cmd/Ctrl + S`
4. Verify:
   - Code formats automatically
   - Imports organize automatically
   - No double-formatting or jerking
   - No ESLint/Prettier errors in problems panel

## Key Differences from ESLint/Prettier

- Use `npx ultracite fix` instead of `prettier --write` (formats + fixes + organizes imports)
- Use `npx ultracite lint` instead of `eslint`
- Biome is **much faster** (written in Rust)
- Zero config by default - trust Ultracite's presets
- Import sorting is built-in, no extra plugins needed

## Troubleshooting

### Double formatting on save?
**Symptom:** Code jumps/jerks when pressing Cmd+S
**Fix:** 
- Ensure `formatOnSave: false` in `.vscode/settings.json`
- Check your user settings don't have conflicting formatter settings
- Only use `codeActionsOnSave` with Biome actions

### Linting CSS/Tailwind errors?
**Symptom:** `Unexpected unknown at-rule: apply`
**Fix:** Disable `noUnknownAtRules` in biome.jsonc (see section 8)

### Type errors in Next.js pages?
**Symptom:** `Parameter 'item' implicitly has an 'any' type`
**Fix:** Add explicit type annotations:
```typescript
type Item = NonNullable<QueryResultType>["items"][number];
data.map((item: Item) => ...)
```

### Next.js build fails with PageNotFoundError?
**Symptom:** `Cannot find module for page: /[...slug]`
**Fix:** Add error handling in `generateStaticParams`:
```typescript
export async function generateStaticParams() {
  try {
    const slugs = await client.fetch(queryPaths);
    if (!Array.isArray(slugs) || slugs.length === 0) {
      return [];
    }
    return slugs.map(slug => ({ slug: slug.split("/").filter(Boolean) }));
  } catch (error) {
    console.error("Error fetching paths:", error);
    return [];
  }
}

export const dynamicParams = true; // Allow runtime generation
```

### Sanity redirects causing type errors?
**Symptom:** `Type 'boolean | null' is not assignable to type 'boolean'`
**Fix:** See section 6 - ensure redirects handle null values

## Quick Command Reference

```bash
# Format entire project
pnpm format

# Lint entire project
pnpm lint

# Build all packages
pnpm build

# Format & lint specific package
cd apps/web && pnpm format && pnpm lint

# Run in watch mode (for development)
cd apps/web && npx ultracite lint --watch
```

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.