创建项目
yarn create react-app react-app --template typescript
yarn add --dev --exact prettier
echo {}> .prettierrc.json
npx mrm@2 lint-staged
"lint-staged": {
"*.{js,css,md,ts.tsx}": "prettier --write"
}
yarn add eslint-config-prettier -D
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
"prettier"
]
}
yarn add @commitlint/config-conventional @commitlint/cli -D
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
若出现报错.prettierrc.json,修改编辑器 编码 为 utf-8
✖ prettier --write:
[error] Invalid configuration file `commitlint.config.js`: JSON Error in D:\code\react-jira-typescript\.prettierrc.json:
[error]
[error] > 1 | ��{}
[error] | ^
[error] 2 |
[error] 3 |
[error]
[error] Unexpected token "�" (0xFFFD) in JSON at position 0 while parsing "��{\u0000}\u0000\r\u0000\n\u0000"
[error]
[error] > 1 | ��{}
[error] | ^
[error] 2 |
[error] 3 |
[error]
husky - pre-commit hook exited with code 1 (error)