Skip to content

script-utils/commitlint-forbidden-patterns

A commitlint rule that refuses a commit message matching a pattern from the UNPUBLISHED forbidden-patterns list — in its header, its body or its footer.

The release already refuses a changelog section carrying such a pattern, but a changelog section holds commit SUBJECTS only, so a body line was never scanned by anything: it reached the public history the moment the commit was pushed, and a pushed commit with descendants cannot be cleaned without rewriting published history. The commit-msg hook is the one point where a body is checked before it exists anywhere else.

The list comes from the same place as the release’s: the file named by the FORBIDDEN_PATTERNS_FILE environment variable (see forbidden-patterns.ts). The rule passes when nothing is configured, so a consumer who has not set it sees no change at all.

Function Description
noForbiddenPatternsRule Checks the whole commit message — header, body and footer — against the forbidden patterns. Only the always condition is meaningful: never would require every line to carry a forbidden pattern, so it is treated the same way rather than inverted.
Variable Description
forbiddenPatternsPlugin The commitlint plugin carrying noForbiddenPatternsRule.
NO_FORBIDDEN_PATTERNS_RULE_NAME The name the rule is registered under.