新版绘管家 APP

王家程 bd3863bf10 test: husky hace 11 meses
.hbuilderx fe4d5b9cdd init hace 11 meses
.husky bd3863bf10 test: husky hace 11 meses
.vscode ab8e014606 test hace 11 meses
pages ab8e014606 test hace 11 meses
static fe4d5b9cdd init hace 11 meses
.eslintrc.js ab8e014606 test hace 11 meses
.gitignore fe4d5b9cdd init hace 11 meses
.npmrc bd3863bf10 test: husky hace 11 meses
.stylelintrc.js fe4d5b9cdd init hace 11 meses
App.vue fe4d5b9cdd init hace 11 meses
README.md bd3863bf10 test: husky hace 11 meses
commitlint.config.js fe4d5b9cdd init hace 11 meses
index.html fe4d5b9cdd init hace 11 meses
main.ts bd3863bf10 test: husky hace 11 meses
manifest.json fe4d5b9cdd init hace 11 meses
package.json bd3863bf10 test: husky hace 11 meses
pages.json fe4d5b9cdd init hace 11 meses
pnpm-lock.yaml bd3863bf10 test: husky hace 11 meses
prettier.config.js fe4d5b9cdd init hace 11 meses
tsconfig.json ab8e014606 test hace 11 meses
uni.scss fe4d5b9cdd init hace 11 meses
vite.config.ts fe4d5b9cdd init hace 11 meses

README.md

huiguanjia-app

hbuilderx 创建模板工程 + 第三方依赖支持

husky 配置

安装 husky

nodejs >= 18

pnpm add husky@8.0.3 -D

配置 package.json

配置该脚本后,install 后会自动执行该命令

script : { "prepare": "husky install" }

添加 git 钩子

npx husky add .husky/pre-commit "pnpm pre-commit"

安装 lint-staged

用于只检查暂存区的文件

pnpm add lint-staged -D

配置 lint-staged

  "lint-staged": {
    "*.{vue,js,ts,jsx,tsx}": [
      "pnpm format",
      "pnpm lint"
    ],
    "*.{css,scss,vue,html}": [
      "pnpm format",
      "pnpm lint:style"
    ]
  }

安装 eslint 和配置

配置 lint 脚本命令

添加 husky commit 钩子

npx husky add .husky/pre-commit "npm run lint"

安装和配置 commitlint

添加 husky commit type校验 钩子

npx husky add .husky/commit-msg "npx --no-install commitlint --edit $HUSKY_GIT_PARAMS"

问题1: husky 不生效?

找到项目的.git 文件,查看是否有hooks目录及文件,没有的话,手动安装husky;如有hooks目录,尝试删除该目录后卸载husky后重新安装,重新设置husky钩子函数