-
Install Husky as a dev dependency:
npm install husky --save-dev
-
Initialize Husky:
npx husky install
-
Set up the pre-commit hook to run tests:
npm pkg set scripts.prepare="husky install" npx husky add .husky/pre-commit "npm test"
-
Install Prettier as a dev dependency with an exact version:
yarn add --dev --exact prettier
-
Create a
.prettierrc
file with default settings:node --eval "fs.writeFileSync('.prettierrc','{}\n')"
-
Create a
.prettierignore
file to ignore artifacts:# Ignore artifacts: build coverage
- Initialize ESLint configuration:
npx eslint --init
-
Install the necessary packages:
yarn add -D eslint-config-prettier eslint-plugin-prettier
-
Add them to
eslintrc.js
:module.exports = { ... extends: ["airbnb-base", "prettier", "plugin:prettier/recommended"], ... };
-
Install lint-staged as a dev dependency:
yarn add -D lint-staged
-
Create a
.lintstagedrc.json
file and define staged tasks:{ "*.js": ["eslint", "prettier --write"], "*.{js,ts,json,html}": "prettier --write" }
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
npm install --save-dev @commitlint/{cli,config-conventional,prompt-cli}
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
{
"scripts": {
"commit": "commit"
}
}
git add .
npm run commit
yarn add -D cz-git