vite-vue3-typescript
2023年02月24日
一、根目录>.husky
.husky
文件夹创建过程如下:
-
package.json
增加命令"scripts": {
"start": "vite",
"tsc": "tsc --noEmit",
"build": "tsc && vite build",
"lint-staged": "lint-staged",
"postinstall": "husky install",
"prettier": "prettier --write src/**/*.{ts,tsx}",
"stylelint-fix": "stylelint src/**/*.scss --fix",
"eslint-fix": "eslint src --ext .jsx,.js,.ts,.tsx --fix",
"commitlint": "commitlint --config commitlint.config.js -e -V"
}, -
运行命令
npm run postinstall
,将会自动创建.husky
文件
1.1 commit-msg
commit-msg
脚本生成过程如下:
-
package.json
添加命令如下"scripts": {
"start": "vite",
"tsc": "tsc --noEmit",
"build": "tsc && vite build",
"lint-staged": "lint-staged",
"postinstall": "husky install",
"prettier": "prettier --write src/**/*.{ts,tsx}",
"stylelint-fix": "stylelint src/**/*.scss --fix",
"eslint-fix": "eslint src --ext .jsx,.js,.ts,.tsx --fix",
"commitlint": "commitlint --config commitlint.config.js -e -V"
}, -
根目录运行命令
npx husky add .husky/commit-msg "npm run commitlint"
,生成文件如下:#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run commitlint
1.2 pre-commit
commit-msg
脚本生成过程如下:
-
package.json
添加命令如下"scripts": {
"start": "vite",
"tsc": "tsc --noEmit",
"build": "tsc && vite build",
"lint-staged": "lint-staged",
"postinstall": "husky install",
"prettier": "prettier --write src/**/*.{ts,tsx}",
"stylelint-fix": "stylelint src/**/*.scss --fix",
"eslint-fix": "eslint src --ext .jsx,.js,.ts,.tsx --fix",
"commitlint": "commitlint --config commitlint.config.js -e -V"
}, -
根目录运行命令
npx husky add .husky/commit-msg "npm run commitlint"
,生成文件如下:#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run lint-staged
二、根目录>.vscode
2.1 settings.json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"eslint.options": {
"extensions": [".ts", ".tsx"]
},
"eslint.validate": ["typescript", "typescriptreact"],
"stylelint.validate": ["css", "scss"]
}
2.2 extensions.json
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint",
"EditorConfig.EditorConfig",
"Gruntfuggly.todo-tree"
],
"unwantedRecommendations": []
}