Shared Prettier config for consistent code formatting.
- Prettier 3 is a peer dependency and must be installed in your project.
pnpm add --save-dev prettier @dnd-mapp/config-prettierReference the config from a .prettierrc file in your project root.
"@dnd-mapp/config-prettier"To add your own options, re-export the config from a prettier.config.js file instead.
import config from '@dnd-mapp/config-prettier';
export default {
...config,
printWidth: 100,
};| Config | Import path | Description |
|---|---|---|
base |
@dnd-mapp/config-prettier/base |
The default config for any project |
organize-imports |
@dnd-mapp/config-prettier/organize-imports |
Extends base with the organize imports plugin |
The package root, @dnd-mapp/config-prettier, resolves to base.
Every config ships with type declarations. Each one is typed as a Prettier Config, so it works in a prettier.config.ts file.
This config includes everything from base and adds prettier-plugin-organize-imports. The plugin sorts and removes unused imports when Prettier formats a file.
The plugin is an optional peer dependency, so install it together with typescript, which it requires. The supported versions are prettier-plugin-organize-imports 4 and typescript 6.
pnpm add --save-dev prettier prettier-plugin-organize-imports typescript @dnd-mapp/config-prettierThen re-export the config from a prettier.config.js file.
export { default } from '@dnd-mapp/config-prettier/organize-imports';| Option | Value | Description |
|---|---|---|
printWidth |
120 |
Wraps code at 120 columns |
quoteProps |
'consistent' |
Quotes object properties only if one requires it |
singleQuote |
true |
Uses single quotes instead of double quotes |
The config has one override. Files that match *.yaml or *.yml use double quotes, so singleQuote is false for them.
The config does not set tabWidth. Prettier reads it from the .editorconfig file in your project, so set indent_size there.
Notable changes for consumers of this package are listed in the changelog.
Contributions are welcome. See the contributing guide for details.
MIT © D&D Mapp