基于create-react-app使用typescript开发项目
npx create-react-app jira --template typescript
问题一:项目中目录的引用,避免多个…/…/
在tsconfig.json文件中加入baseUrl: “./src”,
问题二:团队统一的格式化规则,项目中安装格式化插件prettier
// https://prettier.io/docs/en/install.html
//第一步:
yarn add --dev --exact prettier
//第二步:
echo {}> .prettierrc.json
touch .prettierignore
//内容为:
build
coverage
//内容结束,继续
//第三步:
//Pre-commit Hook
npx mrm lint-staged
// prettier与eslint一起工作时,有冲突,需要安排一下eslint-config-prettier
yarn add eslint-config-prettier -D
问题三:提交代码时,自动检查是否按规则提交
// https://github.com/conventional-changelog/commitlint
// https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional
//安装
yarn add @commitlint/{config-conventional,cli}
//执行命令
echo “module.exports = {extends: [’@commitlint/config-conventional’]}” > commitlint.config.js