upthen's personal prettier-config
- Install
npm i prettier @upthen/prettier-config@latest
- Set prettier
Add prettier config in package.json like the following codes:
{
...
"prettier": "@upthen/prettier-config",
}
- Use in terminal
npx prettier --check --write path
npx prettier --check --write .
# or
npx prettier -c -w .
# . is the path of files you want to format.
- Use With VsCode Extension: Prettier
- Install Prettier Extension
- Add the following config in VsCode settings.json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
- If you have some custom setting config in your workspace settings.json, Confirm the prettier config won't be override. You may need to add the following config into it.
// workspace setttings.json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
[!IMPORTANT] Confirm to add the above config into settings.json, or it may not effects when you enter Ctrl + S or Command + S with VsCode Extension.