Commitlint plugin to enforce the use of spend directives in commit messages.
Note: Purposefully does not support ISO date suffixes or negative time values, since they do not make sense in the context of a commit message.
- condition:
body
ends with a valid spend directive - rule:
always
- Install the plugin:
npm i -D commitlint-plugin-spend
yarn add -D commitlint-plugin-spend
pnpm add -D commitlint-plugin-spend
bun add -d commitlint-plugin-spend
- Add the plugin to your
commitlint
configuration:
{
"extends": ["@commitlint/config-conventional"],
"plugins": ["commitlint-plugin-spend"]
}
- Configure the
spend
rule in yourcommitlint
configuration:
{
"rules": {
"spend": [2, "always"]
}
}
feat: implement user authentication
/spend 2h 30m
fix: resolve database connection timeout
/spend_time 1d 3h 15m
refactor: optimize API response handling
/spend 1mo 2w 3d 4h 5m
feat: implement user authentication
/spend
Error: Spend directive must contain at least one time value
fix: resolve database connection timeout
/spend 25h 70m
Error: The time value "25h" exceeds the maximum value for "h" (max value: 23)
refactor: optimize API response handling
/spend 30m 2h 1d
Error: Time values are not in the correct order. Time values must be ordered from largest to smallest unit