dragonwong / blog

a blog based on github page
dragonwong.github.io/blog/
9 stars 4 forks source link

在项目中配置 pre-commit 强制检查 eslint #61

Open dragonwong opened 1 year ago

dragonwong commented 1 year ago

步骤

1、安装 git hooks 库:husky

npm install husky --save-dev

2、开启 git hooks

npx husky install

并在 package.json 添加安装后自动执行的命令

{
  "scripts": {
    "postinstall": "husky install"
  }
}

3、创建一个 pre-commit 钩子

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

参考