Skip to content

nico-i/commitlint-plugin-spend

Repository files navigation

commitlint-plugin-spend

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.

Available rules

spend

Usage

  1. 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
  1. Add the plugin to your commitlint configuration:
{
  "extends": ["@commitlint/config-conventional"],
  "plugins": ["commitlint-plugin-spend"]
}
  1. Configure the spend rule in your commitlint configuration:
{
  "rules": {
    "spend": [2, "always"]
  }
}

Examples

Valid commit messages

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

Invalid commit messages

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

License

MIT

About

A commitlint plugin that requires the GitLab /spend or /spend_time directive in commit messages

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •