Skip to content

base

npm version License: MIT Node.js

> Base Oxfmt configuration with the same output as @jmlweb/prettier-config-base, at a fraction of the time. Recommended formatter.

  • ⚡ 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’s sort-imports defaults
  • 🎨 Tailwind sorting built in: One option, no plugin required
  • 🧩 Extensible: Plain config object to spread into your oxfmt.config.ts
Terminal window
npm install --save-dev @jmlweb/oxfmt-config-base oxfmt

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.

<!– 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',
};
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

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.

  • ✅ New projects that need fast formatting (recommended)
  • ✅ Migrating from @jmlweb/prettier-config-base without 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).

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'],
},
});

@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,
});
import baseConfig from '@jmlweb/oxfmt-config-base';
import { defineConfig } from 'oxfmt';
export default defineConfig({
...baseConfig,
printWidth: 100,
ignorePatterns: ['generated/**'],
});
{
"scripts": {
"format": "oxfmt",
"format:check": "oxfmt --check"
}
}
Terminal window
npm run format # Format all files
npm run format:check # Check without modifying files
  • 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.

  • oxfmt (>=0.72.0)

Breaking: import sorting is enabled with Perfectionist’s default groups, so the first run reorders imports.

  1. Upgrade the package
  2. If ESLint still sorts your imports, set sortImports: false (see Projects Still Linted by ESLint)
  3. Otherwise run npm run format once and commit the result

See the Changelog for details.

MIT