prettier-config-xo
raw JSON → 2.0.2 verified Sat Apr 25 auth: no javascript
Prettier shareable config that enforces the XO code style. Current stable version is 2.0.2, released November 2025, with active maintenance via GitHub Actions CI/CD. Key differentiator: it provides a zero-config Prettier setup directly matching XO's opinionated style, including optional space-based indentation. Ships TypeScript type definitions and supports ESM via exports field. v2.0 breaking change introduced mandatory trailing commas to align with XO 0.41.0.
Common errors
error Cannot find module 'prettier-config-xo' ↓
cause Package not installed or not in node_modules.
fix
Run
npm install --save-dev prettier prettier-config-xo. error ReferenceError: require is not defined ↓
cause Using CJS `require` in an ESM context (e.g., type: 'module' in package.json).
fix
Use
import config from 'prettier-config-xo' or use dynamic import. error Module parse failed: Unexpected token (1:0) ↓
cause Likely using an outdated bundler that doesn't understand package.json exports.
fix
Update bundler to support 'exports' field or use a direct path like
./node_modules/prettier-config-xo/index.js. Warnings
breaking Trailing commas are now enforced in v2.0.0 to match XO 0.41.0. Existing codebases may need to run Prettier to add trailing commas. ↓
fix Run `npx prettier --write .` to auto-apply trailing commas. If you need to preserve no trailing commas, override `trailingComma: 'none'` in your config.
breaking The /space subpath export replaced the prior pattern for spaces. If you used a different subpath in v1.x, it may not work in v2. ↓
fix Use the correct subpath: `require('prettier-config-xo/space')` or `import config from 'prettier-config-xo/space'`.
gotcha Using `require('prettier-config-xo')` in an ESM context may fail if your project's type is 'module'. ↓
fix Use dynamic import: `const config = await import('prettier-config-xo');` or switch to ESM import syntax.
deprecated The `main` field in package.json no longer points to the default export; use the `exports` field. ↓
fix If you rely on resolution via `main`, update to use the package name directly or specify `exports` in your own config.
Install
npm install prettier-config-xo yarn add prettier-config-xo pnpm add prettier-config-xo Imports
- default config wrong
const config = require('prettier-config-xo')correctimport config from 'prettier-config-xo' - space config wrong
import spaceConfig from 'prettier-config-xo'correctimport spaceConfig from 'prettier-config-xo/space' - type inference
import type { Config } from 'prettier-config-xo'
Quickstart
// 1. Install: npm install --save-dev prettier prettier-config-xo
// 2. In package.json:
{
"name": "my-project",
"version": "1.0.0",
"prettier": "prettier-config-xo"
}
// 3. To extend in a prettier.config.js:
const xoConfig = require('prettier-config-xo');
module.exports = {
...xoConfig,
semi: false // Custom override
};