script-utils/forbidden-patterns
An UNPUBLISHED list of patterns that a release must never publish, read from a file the repository does not contain.
The list exists for vocabulary that is private to one maintainer’s machine — an internal tracker’s ids, the short names of their projects — and which a commit subject can carry straight into a generated changelog section. Neither of the two obvious homes works for it: a literal in this library would ship the list to every consumer on npm, and a checked-in per-repository config would publish it in every public repository that used it, permanently. So the list is named by the FORBIDDEN_PATTERNS_FILE_ENV_VARIABLE environment variable (which a gitignored .env can set), points at a file outside the repository, and is a no-op wherever it is not set — a consumer who has not configured it sees no change at all.
The file holds one pattern per line. Blank lines and lines starting with # are ignored. A line written as a regular expression literal — /\bfoo\b/i — takes the flags it names; any other line is a case-sensitive regular expression source. The global and sticky flags are dropped, since a match here is a yes/no question asked of one line at a time.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| ForbiddenPatternMatch | One line of text that a forbidden pattern matched. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| findForbiddenPatternMatches | Finds every line of text that one of patterns matches. |
| readForbiddenPatterns | Reads the forbidden patterns from the file FORBIDDEN_PATTERNS_FILE_ENV_VARIABLE names, loading the optional .env first. An unset or blank variable means no list is configured, and yields no patterns. A variable that IS set but names a file that cannot be read throws instead of yielding none: a guard that switches itself off because its list moved is precisely the silent failure it exists to prevent. |
Variables
Section titled “Variables”| Variable | Description |
|---|---|
| FORBIDDEN_PATTERNS_FILE_ENV_VARIABLE | The environment variable naming the forbidden-patterns file. |