noTsIgnore
Summary
Section titled Summary- Diagnostic Category:
lint/nursery/noTsIgnore
- This rule has a safe fix.
- The default severity of this rule is warning.
- Sources:
- Inspired from
ban-ts-comment
- Inspired from
Description
Section titled DescriptionPrevents the use of the TypeScript directive @ts-ignore
.
The directive @ts-ignore
suppresses all compilation errors, even ones that could be considered bugs
coming from an upstream library or the compiler itself. If you use @ts-ignore
, it won’t be possible to know
when and if the bug is fixed.
The rule promotes the use the directive @ts-expect-error
, which is meant to raise an error if there aren’t any errors.
This means that once the bug is fixed, you can delete the directive, safely.
Examples
Section titled ExamplesInvalid
Section titled Invalid// @ts-ignorelet foo;
code-block.ts:1:4 lint/nursery/noTsIgnore FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Unsafe use of the @ts-ignore directive found in this comment.
> 1 │ // @ts-ignore
│ ^^^^^^^^^^
2 │ let foo;
3 │
ℹ The directive is applied to this line.
1 │ // @ts-ignore
> 2 │ let foo;
│ ^^^
3 │
ℹ The @ts-ignore directive suppresses any kind of error, even possible errors that might be fixed by upstream libraries or the compiler itself.
ℹ Safe fix: Use the @ts-expect-error directive instead.
1 │ - //·@ts-ignore
1 │ + //·@ts-expect-error
2 2 │ let foo;
3 3 │
Valid
Section titled Valid// @ts-expect-errorlet foo;
How to configure
Section titled How to configure{ "linter": { "rules": { "nursery": { "noTsIgnore": "error" } } }}