buildConventionalCommitRegex
Builds a regular expression matching the subject line of a Conventional Commits message.
The returned regex exposes four capture groups:
- type
- scope (or
undefinedwhen absent) - breaking marker (
'!'orundefined) - description
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | ConventionalCommitOptions | Constrain accepted types/scopes and toggle scope requirement. |
Returns
Section titled “Returns”RegExp — Regex anchored on ^...$ matching the subject line only.
Examples
Section titled “Examples”Match the default Conventional Commits format
Section titled “Match the default Conventional Commits format”Returns a regex matching type(scope)?!?: description on the subject line.
Restrict accepted types and require a scope
Section titled “Restrict accepted types and require a scope”Constrain accepted types and force the scope segment to be present.
Related Types
Section titled “Related Types”ConventionalCommitOptions
Section titled “ConventionalCommitOptions”Options shared by buildConventionalCommitRegex, parseConventionalCommit,
and isConventionalCommit to constrain the accepted commit format.
