Skip to content

Commented-out code (ARCH3208)

Key typescript.quality.commented-out-code · Severity info · Category quality

Flags a comment that is code rather than prose: its text parses as TypeScript (TSX in a .tsx file, including {/* ... */} in JSX) with no syntax error and holds more than a lone word, or at least half of its lines are complete statements. It is never compiled, so it drifts from the code around it. JSDoc, triple-slash directives, @ts-/eslint/prettier pragmas, TODO-style markers, licence headers, URLs and notes after code on the same line are left alone.

export function total(order: Order) {
// const discount = order.customer.discount
// order.total -= order.total * discount
return order.lines.reduce((s, l) => s + l.amount, 0)
}
{/* <Banner title="Sale" onClose={close} /> */}
export function total(order: Order) {
// The discount is applied by the caller, after tax.
return order.lines.reduce((s, l) => s + l.amount, 0)
}