base
> Base Oxfmt configuration with the same output as @jmlweb/prettier-config-base, at a fraction of the time. Recommended formatter.
✨ Features
Section titled “✨ Features”- ⚡ Fast: Oxfmt is written in Rust and formats a whole repository in milliseconds
- 🔁 Prettier-compatible: Same options and output as
@jmlweb/prettier-config-base - 🔤 Import sorting: Same order as
eslint-plugin-perfectionist’ssort-importsdefaults - 🎨 Tailwind sorting built in: One option, no plugin required
- 🧩 Extensible: Plain config object to spread into your
oxfmt.config.ts
📦 Installation
Section titled “📦 Installation”npm install --save-dev @jmlweb/oxfmt-config-base oxfmt🚀 Quick Start
Section titled “🚀 Quick Start”Create oxfmt.config.ts in your project root:
import baseConfig from '@jmlweb/oxfmt-config-base';import { defineConfig } from 'oxfmt';
export default defineConfig({ ...baseConfig,});> ⚠️ Oxfmt has no extends option and .oxfmtrc.json cannot import packages, so share this config through oxfmt.config.ts.
💡 Examples
Section titled “💡 Examples”Before
Section titled “Before”<!– prettier-ignore –>
import { formatName } from "./format";import type { User } from "./types";import { readFile } from "node:fs/promises";
const user: User = { name: "John", age: 30, email: "john@example.com", role: "admin" }import { readFile } from 'node:fs/promises';
import type { User } from './types';
import { formatName } from './format';
const user: User = { name: 'John', age: 30, email: 'john@example.com', role: 'admin',};📋 Configuration Details
Section titled “📋 Configuration Details”| Option | Value | Why |
|---|---|---|
semi |
true |
Semicolons |
singleQuote |
true |
Single quotes |
tabWidth |
2 |
2-space indentation |
trailingComma |
'all' |
Trailing commas wherever possible |
useTabs |
false |
Spaces, not tabs |
endOfLine |
'lf' |
Unix line endings |
proseWrap |
'preserve' |
Keep markdown wrapping |
printWidth |
80 |
Prettier’s default (Oxfmt defaults to 100) |
sortPackageJson |
false |
Prettier does not sort it, and syncpack owns the order |
sortImports |
see below | Perfectionist’s default groups |
Import Sorting
Section titled “Import Sorting”Oxfmt’s sortImports already shares Perfectionist’s defaults (alphabetical, case-insensitive, blank line between groups); only the default groups differ, so this package sets them:
import { defineConfig } from 'oxfmt';
export default defineConfig({ sortImports: { groups: [ 'type-import', ['value-builtin', 'value-external'], 'type-internal', 'value-internal', ['type-parent', 'type-sibling', 'type-index'], ['value-parent', 'value-sibling', 'value-index'], 'unknown', ], },});Side-effect imports (import './polyfill') are sorted into their group too, so keep order-dependent ones in a separate entry file.
🎯 When to Use
Section titled “🎯 When to Use”- ✅ New projects that need fast formatting (recommended)
- ✅ Migrating from
@jmlweb/prettier-config-basewithout reformatting - ✅ Tailwind class sorting without a Prettier plugin
Need Prettier plugins (for example prettier-plugin-astro)? Oxfmt does not support them; keep @jmlweb/prettier-config-base (maintenance mode).
🔧 Extending the Configuration
Section titled “🔧 Extending the Configuration”Tailwind CSS
Section titled “Tailwind CSS”Replaces @jmlweb/prettier-config-tailwind (maintenance mode):
import baseConfig from '@jmlweb/oxfmt-config-base';import { defineConfig } from 'oxfmt';
export default defineConfig({ ...baseConfig, sortTailwindcss: { stylesheet: './src/index.css', functions: ['clsx', 'cn'], },});Projects Still Linted by ESLint
Section titled “Projects Still Linted by ESLint”@jmlweb/eslint-config-base (maintenance mode) sorts imports with eslint-plugin-simple-import-sort, which disagrees with this order. Disable Oxfmt’s sorting until you move to @jmlweb/oxlint-config-base:
import baseConfig from '@jmlweb/oxfmt-config-base';import { defineConfig } from 'oxfmt';
export default defineConfig({ ...baseConfig, sortImports: false,});Other Options
Section titled “Other Options”import baseConfig from '@jmlweb/oxfmt-config-base';import { defineConfig } from 'oxfmt';
export default defineConfig({ ...baseConfig, printWidth: 100, ignorePatterns: ['generated/**'],});📝 Usage with Scripts
Section titled “📝 Usage with Scripts”{ "scripts": { "format": "oxfmt", "format:check": "oxfmt --check" }}npm run format # Format all filesnpm run format:check # Check without modifying files📋 Requirements
Section titled “📋 Requirements”- Node.js >= 22.12.0
- Oxfmt >= 0.72.0
> Markdown, MDX, HTML, Vue and Svelte are formatted by a Prettier build bundled in the oxfmt npm package. The standalone binary skips them, so install from npm.
📦 Peer Dependencies
Section titled “📦 Peer Dependencies”oxfmt(>=0.72.0)
🔗 Related Packages
Section titled “🔗 Related Packages”@jmlweb/oxlint-config-base- Oxlint config, the linter to pair with this formatter@jmlweb/prettier-config-base- Prettier equivalent (maintenance mode)@jmlweb/eslint-config-base- ESLint config, compatible whensortImportsis off (maintenance mode)- Migrate to Oxc - Move a project from the
@jmlwebPrettier/ESLint packages - Migrate from Prettier - Official guide
🔄 Migration Guide
Section titled “🔄 Migration Guide”From 0.1.x to 0.2.0
Section titled “From 0.1.x to 0.2.0”Breaking: import sorting is enabled with Perfectionist’s default groups, so the first run reorders imports.
- Upgrade the package
- If ESLint still sorts your imports, set
sortImports: false(see Projects Still Linted by ESLint) - Otherwise run
npm run formatonce and commit the result
See the Changelog for details.
📄 License
Section titled “📄 License”MIT