When code review finds duplicated logic or repeated formatting/constants, treat it as a “single source of truth” violation. Factor shared logic into a helper/module and reuse it everywhere; avoid hardcoded literals where an existing helper/constant exists; and keep established idioms consistent.
Guidelines:
type New = Old;) or imported from a shared module.timer.unref?.() pattern over verbose type guards when they’re equivalent).undefined immediately overwritten on the next line); remove dead assignments when refactoring.Example (helper extraction):
// helpers.ts
export function extractParentToolNames(generationConfig: unknown): string[] {
// ... shared extraction logic ...
return names;
}
// call sites
const names = extractParentToolNames(generationConfig);
Example (constant for repeated literals in tests):
const INITIAL_CONTENT = 'original content';
expect(input.content).not.toBe(INITIAL_CONTENT);
Enter the URL of a public GitHub repository