Skip to content

ban-ts-comment

Reports a @ts-ignore comment, a @ts-nocheck comment before the first statement, and a @ts-expect-error comment whose description is shorter than three characters (// @ts-expect-error: the API types are wrong is fine). Line and block comments are read. @ts-check is not reported.

@ts-ignore hides every type error on the next line and keeps hiding them after the code changes, so a later, real error on that line is never shown. @ts-nocheck turns checking off for the whole file. @ts-expect-error is safer, because the compiler complains when the error is gone, but without a reason nobody knows when it is safe to remove.

To fix, remove the error with a proper type, or use @ts-expect-error with a short reason.

Reported
let a = 1;
// @ts-ignore
a = "";
// @ts-expect-error
a = "";
// @ts-expect-error: not a number
a = "";
/* @ts-ignore */
/**
* @ts-expect-error
*/
// @ts-check
// @ts-nocheck
/// @ts-ignore
js:
lint:
rules:
ban-ts-comment: warn # off (default), warn, error

Enabled by the presets: js/typescript-eslint-recommended, js/biome-recommended.

Suppress one line with sudsy-disable-next-line ban-ts-comment in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
typescript-eslint ban-ts-comment partial the options (minimumDescriptionLength, per-directive settings, descriptionFormat) keep their defaults