Skip to content

no-union-in-comment

Flag a comment that lists a string field's allowed values instead of the type listing them.

Why

A broad string annotation does not express a closed set documented beside it.

Fix

If the list is exhaustive, express it as a string-literal union; keep examples and runtime constraints documented separately.

Examples

Before — flagged Do not leave allowed values in a comment
src/record.ts
interface R {
kind: string; // 'aa' | 'bb'
}
After — preferred Encode allowed values in the type
src/record.ts
interface R {
kind: "aa" | "bb";
}