OnrampLab / next-starter

A starter project for Next.js with TypeScript
next-starter-eight-iota.vercel.app
MIT License
3 stars 1 forks source link

Force using husky and commitlint to fix eslint erros and lint commit message on git pre-commit #98

Closed koshuang closed 3 years ago

koshuang commented 3 years ago

Issue

希望能在 commit 時,順便做 eslint 檢查且自動 fix,以避免到時候在 CI 上才發現 linting 的錯誤。

Solution

  1. 自動安裝 husky setting
    • 目前已經有用 husky,但沒有預設安裝,因此可以在 package.json 上加上 postinstall 讓他永遠去裝 husky 並去新增對應的 git hook
  2. 加上 huskey settging
    • 讓我們可以在 git precommit hook 設定想要執行的指令
  3. 加入 commitlint package,讓 pre-commit hook 也可以順便檢查 commit message 是否有符合我們制定的標準。

Implement

Document