Skip to content

Commit

Permalink
Fix commands in README
Browse files Browse the repository at this point in the history
  • Loading branch information
bokub committed Jan 15, 2024
1 parent 6355c52 commit c72f15a
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
</p>
</h2>

#### Install
#### Base setup

Install required packages:

```bash
# With npm
Expand All @@ -21,27 +23,31 @@ npm i -D prettier @bokub/prettier-config
yarn add -D prettier @bokub/prettier-config
```

#### Add the following to your `package.json`:
Add the config to your `package.json`:

```json
{
"prettier": "@bokub/prettier-config"
}
```bash
npm pkg set prettier="@bokub/prettier-config"
```

#### _Optional:_ Setup pre-commit hook with husky
#### _Optional:_ Setup pre-commit hook with husky & lint-staged

Install husky & lint-staged:

```bash
npx mrm@2 lint-staged
npx husky set .husky/pre-commit "npx lint-staged --concurrent false"
# With npm
npm i -D husky lint-staged

# With yarn
yarn add -D husky lint-staged
```

Then, in `package.json`, replace the `lint-staged` config with:
Setup git hook:

```json
"lint-staged": {
"*": "prettier --write --ignore-unknown"
}
```bash
npm pkg set scripts.prepare="husky install"
npx husky install
npx husky set .husky/pre-commit "npx lint-staged --concurrent false"
npm pkg set "lint-staged.*"="prettier --write --ignore-unknown"
```

#### _Optional:_ Run prettier on existing code
Expand All @@ -67,16 +73,13 @@ Then, edit your ESLint configuration file:
"plugins": ["prettier"],
"extends": ["<some-config>", "plugin:prettier/recommended"], // Add to the end of the array
"rules": {
"prettier/prettier": "warn" // Optionally, you can set the error level to warn
}
"prettier/prettier": "warn", // Optionally, you can set the error level to warn
},
}
```

Then, in `package.json`, replace the `lint-staged` config (if it exists) with:
If you have a `lint-staged` configuration, add an ESLint task :

```json
"lint-staged": {
"*": "prettier --write --ignore-unknown",
"*.{js,ts,vue}": "eslint --fix"
}
```bash
npm pkg set "lint-staged[*.{js,ts,vue}]"="eslint --fix"
```

0 comments on commit c72f15a

Please sign in to comment.