Ultracite Documentation

repository·main·Indexed 25 days ago

https://github.com/haydenbleasel/ultracite

A production-grade, zero-configuration preset for ESLint, Biome, and Oxlint designed to be AI-ready and monorepo-compatible. Ultracite provides tools for JavaScript and TypeScript linting and formatting, including a CLI for initialization (`ultracite init`), verification (`ultracite doctor`), and execution (`check` and `fix`). It features AI agent hooks for automatic code formatting with tools like Cursor, Windsurf, and GitHub Copilot, as well as installable AI skills and rule generation to guide AI coding assistants.

Tokens
48.4K
Snippets
108
Records
269
Agent score
84%

What's inside Ultracite

  1. Supported linting and formatting toolchains

    main

    Ultracite provides opinionated presets for three major toolchains. You can choose the one that best fits your project's performance and ecosystem requirements:

    • Biome: A modern, all-in-one toolchain written in Rust.
    • ESLint + Prettier + Stylelint: The most mature and comprehensive linting ecosystem.
    • Oxlint + Oxfmt: The fastest linter available, optimized for speed (50-100x faster than ESLint).
  2. Understand the relationship between Ultracite and underlying engines

    main

    Ultracite is a preset configuration (a curated bundle of rules and settings) that sits on top of an existing toolchain. It is not a standalone linter or formatter engine.

    • The Engine: Tools like Biome, ESLint + Prettier + Stylelint, or Oxlint + Oxfmt perform the actual linting and formatting.
    • The Configuration: Ultracite provides the ready-to-go rulesets for these engines to save you from manual configuration.
  3. Understand the Ultracite regression gate logic

    main

    To prevent noisy CI results, the regression gate compares a head build against a base build interleaved on the same runner. A provider or command is flagged as a regression only if it meets both of the following criteria:

    1. Effect Size: The head/base median ratio is greater than BENCH_REGRESSION_RATIO (default 1.25, meaning >25% slower).
    2. Significance: A one-sided Mann–Whitney U test results in p < BENCH_ALPHA (default 0.05).
  4. Use the TanStack framework preset

    main

    Ultracite provides a dedicated tanstack framework preset that integrates Biome, ESLint, and Oxlint.

    • ESLint: Layers @tanstack/eslint-plugin-query, @tanstack/eslint-plugin-router, and @tanstack/eslint-plugin-start.
    • Biome & Oxlint: Automatically relaxes file-naming conventions for routes/ directories and the generated routeTree.gen.ts files.

    Note for existing users (v7.8.0+):

    • TanStack Query rules have moved from the react preset to the tanstack preset. If your project relies on these rules, you must explicitly opt into the tanstack preset.
    • TanStack Router projects now automatically resolve to the tanstack preset instead of the remix preset.
  5. Manual Migration from Prettier to Ultracite

    main

    If you require full control over the migration process, follow these steps:

    1. Follow the standard Setup steps to install Ultracite.
    2. Manually remove Prettier and any related dependencies from your project.
    3. Manually delete your Prettier configuration files (e.g., .prettierrc, prettier.config.js).
    4. Restart your editor to ensure the new configuration is applied.
  6. Enable ESLint parity via JS plugins

    main

    By default, Ultracite's Oxlint presets run on native Rust rules for maximum speed. To achieve higher parity with ESLint, you can opt-in to the js-plugins preset, which runs JavaScript-based plugins like eslint-plugin-github, eslint-plugin-sonarjs, and oxlint-plugin-react-doctor through Oxlint's JS plugin support.

    Note: This is off by default because it adds dependencies and runs a slower JavaScript lint pass.

    Option 1: Interactive or CLI Setup

    Use the ultracite init command to choose plugins during setup:

    npx ultracite init --linter oxlint --js-plugins eslint-plugin-github eslint-plugin-sonarjs oxlint-plugin-react-doctor

    Option 2: Manual Setup

    If adding manually, install the plugins as dev dependencies:

    npm install -D eslint-plugin-github eslint-plugin-sonarjs oxlint-plugin-react-doctor

    Then update your oxlint.config.ts:

    import { defineConfig } from "oxlint";
    import core from "ultracite/oxlint/core";
    import jsPlugins from "ultracite/oxlint/js-plugins";
    
    export default defineConfig({
      extends: [core, jsPlugins],
      ignorePatterns: core.ignorePatterns,
    });
  7. Follow Ultracite Modern JavaScript/TypeScript standards

    main

    Adhere to these modern syntax patterns:

    • Use arrow functions for callbacks and short functions.
    • Prefer for...of loops over .forEach() or indexed for loops.
    • Use optional chaining (?.) and nullish coalescing (??) for safe property access.
    • Use template literals instead of string concatenation.
    • Use destructuring for object and array assignments.
    • Use const by default; use let only when reassignment is required; never use var.
  8. Configure Oxlint with JS-plugin-based rules

    main

    In version 7.9.3, all JS-plugin-based rules (such as eslint-plugin-github, eslint-plugin-sonarjs, and oxlint-plugin-react-doctor) were moved from the core and framework presets into a single opt-in preset: ultracite/oxlint/js-plugins.

    To use these rules, you must manually install the underlying plugins and extend the new preset alongside your chosen core and framework preset. This ensures that the core, react, next, and tanstack presets run exclusively on Oxlint's native Rust rules for maximum performance.

    Steps to enable JS plugins:

    1. Install eslint-plugin-github, eslint-plugin-sonarjs, and oxlint-plugin-react-doctor as devDependencies.
    2. Extend ultracite/oxlint/js-plugins in your configuration.
  9. Configure Prettier with Ultracite

    main

    To use Ultracite's Prettier configuration, create a prettier.config.mjs file. The configuration includes prettier-plugin-tailwindcss by default. If you use Astro or Svelte, their respective plugins will be inserted before the Tailwind plugin.

    import config from "ultracite/prettier";
    
    export default {
      ...config,
      plugins: ["prettier-plugin-tailwindcss"],
    };