npm install husky -D
add npm-script prepare
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview --port 5050",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"prepare": "husky install"
},
# generate .husky folder in current project
npm run prepare
npx husky add .husky/pre-commit "npm run lint"
Windows下执行报错:husky用法错误,上述命令改为:
npx husky add .husky/pre-commit "npm-run-lint"
# 如果用lint-staged
# npm install lint-staged -D
# npx husky add .husky/pre-commit "npx lint-staged"
再手动修改 .husky/pre-commit
文件, npm-run-lint
改为 npm run lint
每次commit的时候会执行 npm run lint
This template should help get you started developing with Vue 3 in Vite.
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
See Vite Configuration Reference.
npm install
npm run dev
npm run build
Lint with ESLint
npm run lint