yarn add --dev --exact prettier
echo {}> .prettierrc.json
echo build coverage> .prettierignore
npx mrm@2 lint-staged
# 修改package.json中的lint-staged, 添加ts、tsx扩展名
"lint-staged": {
"*.{js,css,md,ts,tsx}": "prettier --write"
}
原因:为了团队代码的一致性,需要在Git提交代码时进行格式化
yarn add -D eslint-config-prettier
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
"prettier"
]
},
yarn add -D @commitlint/config-conventional @commitlint/cli
echo "module.exports = {extends: [‘@commitlint/config-conventional‘]};" > commitlint.config.js
npx husky add .husky/commit-msg ‘npx --no-install commitlint --edit "$1"‘
git commit -m "fix: 配置了代码规范"
原文:https://www.cnblogs.com/marioblog/p/14966748.html