Skip to content

TypeScript · maintainability

no-trailing-value-narration

eslint:no-trailing-value-narration

Flag a trailing comment that repeats the line's numeric value only to name its unit.

Default
error
Fix
none
Languages
typescript

Why

A repeated value can disagree with the expression after either the code or comment changes.

Fix

Put the unit in the identifier and keep comments only when they explain a constraint or non-obvious conversion.

Before / after

Executed by this rule’s unit tests.

Before

Do not narrate the numeric duration

src/timeouts.ts · focus
const staleTime = 5 * 60 * 1000; // 5 minutes

After

Explain a domain constraint

src/timeouts.ts · focus
const timeout = 5 * 60; // 5 minutes for cold starts

Limits

  • Only trailing comments with numeric values and recognized unit words are inspected.

Message IDs

narratesValue

Formerly: trailing-value-narration