Skip to content

base

npm version License: MIT Node.js

> Shared Prettier configuration for consistent code style across projects.

> πŸ”§ Maintenance mode: dependency and security updates only, no new rules. New projects should use @jmlweb/oxfmt-config-base. To migrate, see the migration guide.

  • 🎯 Consistent: one code style for every project
  • πŸ”§ Zero config: sensible defaults out of the box
  • πŸ“¦ Extensible: base for @jmlweb/prettier-config-tailwind
  • πŸ”€ Dual format: ESM and CommonJS builds
Terminal window
npm install --save-dev @jmlweb/prettier-config-base prettier

> πŸ’‘ Upgrading? See the Migration Guide.

Create .prettierrc.mjs (works for ESM and CommonJS projects):

export { default } from '@jmlweb/prettier-config-base';

Alternatives:

{
"prettier": "@jmlweb/prettier-config-base"
}

> ⚠️ In projects with "type": "module", the package.json field can make Prettier warn Ignored unknown option { default: ... } and skip the config. Use .prettierrc.mjs instead.

For CommonJS (.prettierrc.cjs):

module.exports = require('@jmlweb/prettier-config-base');

Before:

const user = { name: 'John', age: 30, email: 'john@example.com' };

After:

const user = { name: 'John', age: 30, email: 'john@example.com' };
Option Value Description
semi true Semicolons at end of statements
singleQuote true Single quotes
tabWidth 2 2-space indentation
trailingComma 'all' Trailing commas everywhere
useTabs false Spaces, not tabs
endOfLine 'lf' LF line endings
proseWrap 'preserve' Keep prose wrapping in Markdown
  • βœ… Existing projects already on Prettier
  • βœ… Zero-config, consistent formatting
  • βœ… A base to extend with your own options

Not for you if:

.prettierrc.mjs
import baseConfig from '@jmlweb/prettier-config-base';
export default {
...baseConfig,
printWidth: 100,
};
{
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}
Terminal window
npm run format # format all files
npm run format:check # check without writing
  • Node.js >= 22.12.0
  • Prettier >= 3.0.0
  • prettier (^3.0.0)

Breaking: Node.js >= 22.12.0 is required (18 and 20 are end-of-life).

  1. Upgrade Node.js to 22.12.0 or later.
  2. Update: npm install --save-dev @jmlweb/prettier-config-base@latest

See the Changelog for details.

MIT