💡项目地址
1 2 3 4 5 6 7 8 9 10 11 12
| ├── .husky ├── .vscode ├── public ├── src │ ├── App.tsx │ ├── index.tsx │ └── react-app-env.d.ts ├── prettier.config.js ├── tsconfig.json ├── package.json └── yarn.lock ├── README.md
|
初始化项目
yarn add create-react-app [app-name] --template typescript
prettier
yarn add -D prettier
1 2 3 4 5 6 7 8 9 10 11 12 13
| module.exports = { semi: false, trailingComma: 'es5', singleQuote: true, printWidth: 80, tabWidth: 3, useTabs: false, bracketSpacing: true, jsxBracketSameLine: false, arrowParens: 'avoid', endOfLine: 'lf', }
|
husky
yarn add -D husky
1 2 3 4
| "scripts": { "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"" }
|
启用 Git 钩子: npx husky install
添加 pre-commit 钩子:npx husky add .husky/pre-commit "yarn prettier"
路径别名
1 2 3 4 5 6 7
| "compilerOptions": { "baseUrl": "src", "paths": { "@/*": ["*"] } }
|
静候补充...