Myles' shared Prettier configuration for (hopefully) all his projects.
A single source of truth for code formatting, so every project stays consistent without copy-pasting settings around.
| Option | Value | Meaning |
|---|---|---|
trailingComma |
"all" |
Trailing commas wherever possible (incl. function args). |
tabWidth |
2 |
Two spaces per indentation level. |
singleQuote |
false |
Use double quotes. |
Everything else falls back to Prettier's defaults.
npm install --save-dev @mylesb/prettier-config prettierRequires Prettier
>=3.0.0.
The simplest option — point Prettier at the package by name:
{
"prettier": "@mylesb/prettier-config"
}If you need to add or override a few options, re-export the shared config and spread it:
// prettier.config.mjs
import mylesPrettierConfig from "@mylesb/prettier-config";
/** @type {import("prettier").Config} */
export default {
...mylesPrettierConfig,
// your overrides here
};Once configured, run Prettier as usual:
# Check that files are formatted
npx prettier . -c
# Format files in place
npx prettier . --write