Skip to content

Format

vp fmt formats code with Oxfmt.

Overview

vp fmt is built on Oxfmt, the Oxc formatter. Oxfmt has full Prettier compatibility and is designed as a fast drop-in replacement for Prettier.

Use vp fmt to format your project, and vp check to format, lint and type-check all at once.

Usage

bash
vp fmt
vp fmt --check
vp fmt . --write

Configuration

Put formatting configuration directly in the fmt block in the root vite.config.ts so all your configuration stays in one place. We do not recommend using .oxfmtrc.json with Vite+.

Oxfmt discovers the nearest vite.config.ts with a fmt block, starting from the working directory and searching parent directories. Running vp fmt from a package directory can therefore use that package's format settings. Running from the workspace root does not apply nested configs to individual files; use fmt.overrides for file- or package-specific options.

For editors, disable nested formatter configs so format-on-save uses the root Vite+ fmt block:

.vscode/settings.json
json
{
  "oxc.fmt.disableNestedConfig": true
}

For the upstream formatter behavior and configuration reference, see the Oxfmt docs.

vite.config.ts
ts
import { defineConfig } from 'vite-plus';

export default defineConfig({
  fmt: {
    singleQuote: true,
  },
});