export type TechLogBehavioralLiteralViolation = Readonly<{ kind: string; index: number; text: string; }>; const korean = /[가-힣]/; const behavioralState = /(다시 시도|찾을 수 없|불러오지 못|못했습니다|만들지 못|없습니다|저장했습니다|삭제했습니다|게시했습니다|보관했습니다|저장 중|처리 중|불러오는 중|검증 중|생성 중|업로드 중|준비하고 있습니다)/; function add( violations: TechLogBehavioralLiteralViolation[], kind: string, index: number, text: string, ): void { const normalized = text.trim(); if (!korean.test(normalized)) return; violations.push(Object.freeze({ kind, index, text: normalized })); } function literalBody(match: RegExpMatchArray, bodyIndex: number): string { return match[bodyIndex] ?? ""; } export function findTechLogBehavioralLiteralViolations( source: string, ): readonly TechLogBehavioralLiteralViolation[] { const violations: TechLogBehavioralLiteralViolation[] = []; for (const match of source.matchAll( /(?:\b[A-Za-z_$][\w$]*\.)?(?:setRequestAnnouncement|setNotice|setSuccess)\(\s*(["'`])([\s\S]*?)\1\s*\)/g, )) { const body = literalBody(match, 2); add(violations, "announcement", match.index ?? 0, body); } for (const match of source.matchAll( /\b(?:pendingLabel|closeLabel|resetLabel|clearLabel|actionLabel|confirmLabel)\s*=\s*(["'`])([\s\S]*?)\1/g, )) { const body = literalBody(match, 2); add(violations, "action-prop", match.index ?? 0, body); } for (const match of source.matchAll(/<(Button|Link)\b[^>]*>\s*([^<{][^<{}]*?)\s*<\/\1>/g)) { add(violations, "action-text", match.index ?? 0, match[2] ?? ""); } for (const match of source.matchAll( /(?:studioFailureMessage|managementFailureMessage)\([\s\S]{0,600}?,\s*(["'`])([\s\S]*?)\1\s*\)/g, )) { const body = literalBody(match, 2); add(violations, "failure-fallback", match.index ?? 0, body); } for (const match of source.matchAll( /<(h1|h2|h3|p|span)\b[^>]*>\s*([^<{][^<{}]*[가-힣][^<{}]*)\s*<\/\1>/g, )) { const body = (match[2] ?? "").trim(); if (behavioralState.test(body)) { add(violations, "behavioral-surface", match.index ?? 0, body); } } for (const match of source.matchAll( /\b(?:title|description|message|empty|emptyLabel|error|errorLabel|loading|loadingLabel)\s*=\s*(["'`])([^"'`\n]*[가-힣][^"'`\n]*)\1/g, )) { const body = match[2] ?? ""; if (behavioralState.test(body)) { add(violations, "behavioral-prop", match.index ?? 0, body); } } return Object.freeze(violations); }