base
> 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.
β¨ Features
Section titled ββ¨ Featuresβ- π― 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
π¦ Installation
Section titled βπ¦ Installationβnpm install --save-dev @jmlweb/prettier-config-base prettier> π‘ Upgrading? See the Migration Guide.
π Quick Start
Section titled βπ Quick Startβ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');π‘ Examples
Section titled βπ‘ ExamplesβBefore:
const user = { name: 'John', age: 30, email: 'john@example.com' };After:
const user = { name: 'John', age: 30, email: 'john@example.com' };π Configuration Details
Section titled βπ Configuration Detailsβ| 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 |
π― When to Use
Section titled βπ― When to Useβ- β Existing projects already on Prettier
- β Zero-config, consistent formatting
- β A base to extend with your own options
Not for you if:
- Tailwind class sorting: use
@jmlweb/prettier-config-tailwind - New projects: use
@jmlweb/oxfmt-config-base
π§ Extending the Configuration
Section titled βπ§ Extending the Configurationβimport baseConfig from '@jmlweb/prettier-config-base';
export default { ...baseConfig, printWidth: 100,};π Usage with Scripts
Section titled βπ Usage with Scriptsβ{ "scripts": { "format": "prettier --write .", "format:check": "prettier --check ." }}npm run format # format all filesnpm run format:check # check without writingπ Requirements
Section titled βπ Requirementsβ- Node.js >= 22.12.0
- Prettier >= 3.0.0
π¦ Peer Dependencies
Section titled βπ¦ Peer Dependenciesβprettier(^3.0.0)
π Related Packages
Section titled βπ Related Packagesβ@jmlweb/prettier-config-tailwind- Extends this config with Tailwind class sorting@jmlweb/oxfmt-config-base- Recommended Oxfmt replacement
π Migration Guide
Section titled βπ Migration Guideβ1.x to 2.0
Section titled β1.x to 2.0βBreaking: Node.js >= 22.12.0 is required (18 and 20 are end-of-life).
- Upgrade Node.js to 22.12.0 or later.
- Update:
npm install --save-dev @jmlweb/prettier-config-base@latest
See the Changelog for details.
π License
Section titled βπ LicenseβMIT