This project was bootstrapped with Create React App.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
- 嵌套路由;
- 安装 eslint 及 ts 插件
yarn add eslint
yarn add @typescript-eslint/parser @typescript-eslint/eslint-plugin
- 配置 eslint 规则: .eslintrc.json
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 11
},
"rules": {
"indent": ["error", 2],
"linebreak-style": ["off", "windows"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
"no-undef": "warn",
"no-unused-vars": "warn",
"no-constant-condition": "warn"
}
}
- vscode 配置:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
"eslint.codeAction.disableRuleComment": {
"enable": false
},
"eslint.debug": true,
- 配置 pre-commit 在 package.json 中配置:
"scripts": {
"lint": "eslint --ext .js,.ts,.tsx src/",
... ...
},
"pre-commit": [
"lint"
]