mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-20 12:42:38 -04:00
refactor(githooks): use non-capturing groups for unread regex captures
The commit-msg header regex captured the optional scope and breaking-change marker but never read them. Make those groups non-capturing so only the type and subject are captured, per review feedback.
This commit is contained in:
@@ -80,14 +80,14 @@ function collectErrors (header) {
|
||||
errors.push(`header is ${header.length} characters; keep it within ${HEADER_MAX_LENGTH}`)
|
||||
}
|
||||
|
||||
const match = /^([^():!]+)(\([^)]*\))?(!)?: (.*)$/.exec(header)
|
||||
const match = /^([^():!]+)(?:\([^)]*\))?(?:!)?: (.*)$/.exec(header)
|
||||
if (!match) {
|
||||
errors.push('header must match "type(optional scope): subject", e.g. "fix(core): handle empty input"')
|
||||
return errors
|
||||
}
|
||||
|
||||
const type = match[1]
|
||||
const subject = match[4]
|
||||
const subject = match[2]
|
||||
|
||||
if (type !== type.toLowerCase()) {
|
||||
errors.push(`type "${type}" must be lower-case`)
|
||||
|
||||
Reference in New Issue
Block a user