https://github.com/bokub/prettier-config
💜 My personal Prettier config & workflow
https://github.com/bokub/prettier-config
prettier prettier-config workflow
Last synced: 7 months ago
JSON representation
💜 My personal Prettier config & workflow
- Host: GitHub
- URL: https://github.com/bokub/prettier-config
- Owner: bokub
- Created: 2020-09-05T08:30:51.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-20T10:58:39.000Z (about 1 year ago)
- Last Synced: 2025-03-17T20:49:50.953Z (7 months ago)
- Topics: prettier, prettier-config, workflow
- Homepage:
- Size: 16.6 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

My personal Prettier config & workflow
#### Base setup
Install required packages:
```bash
# With npm
npm i -D prettier @bokub/prettier-config# With yarn
yarn add -D prettier @bokub/prettier-config
```Add the config to your `package.json`:
```bash
npm pkg set prettier="@bokub/prettier-config"
```#### _Optional:_ Setup pre-commit hook with husky & lint-staged
Install husky & lint-staged:
```bash
# With npm
npm i -D husky lint-staged# With yarn
yarn add -D husky lint-staged
```Setup git hook:
```bash
npx husky init
echo "npx lint-staged --concurrent false" > .husky/pre-commit
npm pkg set "lint-staged.*"="prettier --write --ignore-unknown"
```#### _Optional:_ Run prettier on existing code
```bash
npx prettier --write .
```#### _Optional:_ Setup with ESLint
```bash
# With npm
npm i -D eslint-config-prettier eslint-plugin-prettier eslint# With yarn
yarn add -D eslint-config-prettier eslint-plugin-prettier eslint
```Then, edit your ESLint configuration file:
```jsonc
{
"plugins": ["prettier"],
"extends": ["", "plugin:prettier/recommended"], // Add to the end of the array
"rules": {
"prettier/prettier": "warn", // Optionally, you can set the error level to warn
},
}
```If you have a `lint-staged` configuration, add an ESLint task :
```bash
npm pkg set "lint-staged[*.{js,ts,vue}]"="eslint --fix"
```