新版绘管家 APP

王家程 4fa01eadbd build: vite 11 months ago
.hbuilderx fe4d5b9cdd init 11 months ago
.husky bd3863bf10 test: husky 11 months ago
.vscode ab8e014606 test 11 months ago
src 4fa01eadbd build: vite 11 months ago
types 4fa01eadbd build: vite 11 months ago
.env.development 4fa01eadbd build: vite 11 months ago
.eslintrc.js 4fa01eadbd build: vite 11 months ago
.gitignore fe4d5b9cdd init 11 months ago
.npmrc bd3863bf10 test: husky 11 months ago
.stylelintrc.js 4fa01eadbd build: vite 11 months ago
README.md 4fa01eadbd build: vite 11 months ago
commitlint.config.js fe4d5b9cdd init 11 months ago
index.html 4fa01eadbd build: vite 11 months ago
package.json 4fa01eadbd build: vite 11 months ago
pnpm-lock.yaml 4fa01eadbd build: vite 11 months ago
prettier.config.js fe4d5b9cdd init 11 months ago
tsconfig.json 4fa01eadbd build: vite 11 months ago
uno.config.ts 4fa01eadbd build: vite 11 months ago
vite.config.ts 4fa01eadbd build: vite 11 months ago

README.md

huiguanjia-app

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

使用 vscode 编辑,提交代码,hbuilderx 运行和构建。

名词解释

  • node_modules: 第三方依赖库
  • uni_modules:uni-app 插件市场依赖

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钩子函数