/** * The core of `pnpm lint:copy` (CLAUDE.md §5.6, §7): what a player could read in * a file, and what is wrong with it. The script walks files; this decides. */ import { findForbidden } from './forbidden.js'; export interface CopyProblem { readonly line: number; readonly message: string; } /** * Removes comments, keeping line numbers. Comments are where the rules are * explained, and a rule must be nameable in the file that enforces it. * `//` after a `:` is a URL, not a comment. */ export function stripComments(source: string): string { const blank = (m: string): string => m.replace(/[^\n]/g, ' '); return source .replace(//g, blank) .replace(/\/\*[\s\S]*?\*\//g, blank) .replace(/(? text.slice(0, index).split('\n').length; const problems: CopyProblem[] = []; for (const hit of findForbidden(text)) { problems.push({ line: lineOf(hit.index), message: `'${hit.term}' (${hit.category}): ${hit.why}` }); } for (const m of text.matchAll(DOMI_ALONE)) { problems.push({ line: lineOf(m.index), message: "'Domi' on its own: the product is always Rosea Domi, and Domi never appears alone" }); } return problems.sort((a, b) => a.line - b.line); }