1, Add prettier
1. Add dependencies
yarn add --dev --exact prettier
Copy the code
2. Create a configuration file
echo {}> .prettierrc.json
Copy the code
3. Create the. Prettierignore file and add it
# Ignore artifacts:
build
coverage
Copy the code
4. Add a pre-commit Hook
npx mrm lint-staged
Copy the code
5. Modify Lint-passage under package.json
"lint-staged": {
"*.{js,css,md,ts,tsx}": "prettier --write"
}
Copy the code
6. Add eslint – config – prettier
yarn add eslint-config-prettier -D
Add “prettier” under eslintConfig–>extends in package. Jon
2. Add CommitLint
1. Run yarn add -d @commitlint/{config-conventional,cli}.
Echo “module.exports = {extends: [‘@commitlint/config-conventional’]}” > commitlint.config.js
3. Add the Postinstall script to package.json
{
"scripts": {
"postinstall": "husky install"}}Copy the code
NPX husky add. husky/commit-msg “YARN commitlint –edit $1”