Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 1x 1x 15x 15x 165x 165x 2x 2x 2x 14x 8x 2x 2x 2x 2x 15x | /**
* @module scripts/validators/executive-brief-translations/rules/banned-english
* @description Banned-English-phrase scanner for non-English translations
* (e.g. "Executive Brief", "BLUF", "Bottom-Line-Up-Front").
*
* Rule census: extracted from
* `scripts/validate-executive-brief-translations.ts` lines
* 59–80, 206–226. Logic is byte-identical to the original;
* the banned-phrase list and allowlist contexts are
* re-exported unchanged.
*
* @author Hack23 AB
* @license Apache-2.0
*/
/** Banned English phrases that must NOT appear in non-English translations. */
const BANNED_ENGLISH_PHRASES: ReadonlyArray<string> = [
'Executive Brief',
'BLUF',
'Bottom-Line-Up-Front',
'Top Forward Trigger',
'60-Second Read',
'Decision-Grade',
'Decisions',
'Confidence',
'Key Takeaways',
'What Happened',
'What It Means',
];
/** Banned-phrase scan exemptions (phrases that are technical / canonical). */
const BANNED_PHRASE_ALLOWLIST_CONTEXTS: ReadonlyArray<RegExp> = [
/`Executive Brief`/i, // inline code (canonical reference)
/\bdok_id\b/i,
/<!--\s*source-sha:/i,
/<!--\s*dir:\s*rtl\s*-->/i,
];
/** Returns banned English phrases found in `md`, ignoring allowlist contexts. */
export function findBannedEnglishPhrases(md: string): string[] {
const hits: string[] = [];
for (const phrase of BANNED_ENGLISH_PHRASES) {
const re = new RegExp(`\\b${phrase.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')}\\b`, 'i');
if (!re.test(md)) continue;
// Check allowlist contexts on each occurrence.
const allLines = md.split('\n');
let stillFound = false;
for (const line of allLines) {
if (!re.test(line)) continue;
const inAllowlist = BANNED_PHRASE_ALLOWLIST_CONTEXTS.some((ctx) => ctx.test(line));
Eif (!inAllowlist) {
stillFound = true;
break;
}
}
Eif (stillFound) hits.push(phrase);
}
return hits;
}
|