跳至主要内容

Commitlint

用來檢查commit訊息是不是符合規範。

安裝 Commitlint

npm install @commitlint/cli --save-dev

安裝預設規則包

這邊我直接安裝預設好的 詳細連結

npm install @commitlint/config-conventional --save-dev

如果要自訂的化參考Commitlint去撰寫下面的commitlint.config.js

專案下建立commitlint.config.js

module.exports = {
extends: ['@commitlint/config-conventional'],
// ...
};

測試 Commitlint

> echo foo | npx commitlint
⧗ input: foo
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]

✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

範例

Type(功能分類): 訊息
(選用)BREAKING CHANGE: 訊息 是有重大變更的時候才加
(選用)#issue id 可以連結到對應的issue

feat(device list table): update table column width settings #123

BREAKING CHANGE: re-define table setting config

#123

Type介紹

Type用途
feat增加新功能
fix修BUG
build發版相關
chore其他沒有修改原始碼的功能
ci與自動發版相關的修改
docs文件
perf提升效能
refactor重構
revertRevert commit
style調整Coding style
test測試功能(應該是新增或修改單元測試?)