-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c188493
commit 8e457a7
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |