Skip to content

TypeScript · maintainability

no-restated-comment

eslint:no-restated-comment

Flag a single-line comment whose every word already appears on the statement below it.

Default
error
Fix
none
Languages
typescript

Why

A comment that only repeats code adds no context and can become stale independently.

Fix

Delete the comment or replace it with the reason, constraint, or consequence absent from the code.

Before / after

Executed by this rule’s unit tests.

Before

Remove a comment that repeats the statement

src/cache.ts · focus
// Serialize key
const key = serialize(input);

After

Keep the reason the code cannot express

src/cache.ts · focus
// Serialize because the cache key is stable across deploys.
const key = serialize(input);

Limits

  • Directives, protected references, questions, multi-line prose, comments with novel content, and generated files are excluded.

Message IDs

restatesLineBelow