Prettier is a highly effective tool that specializes in handling code formatting styles. ✨ We have bundled our configuration to make it easily shareable across multiple projects.
Install Prettier and the related configuration as a devDependencies
:
pnpm add -D @detra-lab/prettier-config prettier
Reference it in your package.json
:
{
"name": "my-cool-library",
"version": "1.0.0",
"prettier": "@detra-lab/prettier-config"
}
If you don’t want to use package.json
, you can choose any of the supported extensions to export a string, e.g. .prettierrc.json
:
"@detra-lab/prettier-config"
Note: This method doesn't offer a way to extend the configuration and override some properties. If you need to do that, import the file in a
.prettierrc.js
file and export the modifications:
module.exports = {
...require('@detra-lab/prettier-config'),
semi: true
};
Use the --write
flag to format a file in place.
pnpx prettier . --write --ignore-unknown
Check the .prettierrc.json
file if you want to inspect the configuration.
Help us keep the project open and inclusive. Please read and follow our Code of Conduct.