Skip to content

Commit

Permalink
update redame
Browse files Browse the repository at this point in the history
  • Loading branch information
shanquan954 committed Dec 23, 2023
1 parent c188493 commit 8e457a7
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
# Just only a test

## Setting up Husky and Code Quality Tools

### 1. Install Husky

- Install Husky as a dev dependency:
```bash
npm install husky --save-dev
```

- Initialize Husky:
```bash
npx husky install
```

- Set up the pre-commit hook to run tests:
```bash
npm pkg set scripts.prepare="husky install"
npx husky add .husky/pre-commit "npm test"
```

### 2. Install Prettier

- Install Prettier as a dev dependency with an exact version:
```bash
yarn add --dev --exact prettier
```

- Create a `.prettierrc` file with default settings:
```bash
node --eval "fs.writeFileSync('.prettierrc','{}\n')"
```

- Create a `.prettierignore` file to ignore artifacts:
```
# Ignore artifacts:
build
coverage
```

### 3. Install ESLint

- Initialize ESLint configuration:
```bash
npx eslint --init
```

### 4. Install eslint-config-prettier and eslint-plugin-prettier

- Install the necessary packages:
```bash
yarn add -D eslint-config-prettier eslint-plugin-prettier
```

- Add them to `eslintrc.js`:
```javascript
module.exports = {
...
extends: ["airbnb-base", "prettier", "plugin:prettier/recommended"],
...
};
```

### 5. Install lint-staged

- Install lint-staged as a dev dependency:
```bash
yarn add -D lint-staged
```

- Create a `.lintstagedrc.json` file and define staged tasks:
```json
{
"*.js": ["eslint", "prettier --write"],
"*.{js,ts,json,html}": "prettier --write"
}
```

### 6. Add `npx lint-staged` to pre-commit hook

```bash
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

0 comments on commit 8e457a7

Please sign in to comment.