{"record":{"id":"aa061e90ae81b11f","repo":"oxc-project/oxc","slug":"enforce-using-ts-expect-error-over-ts-ignore","errorCode":null,"errorMessage":"Enforce using `@ts-expect-error` over `@ts-ignore`","messagePattern":"Enforce using `@ts-expect-error` over `@ts-ignore`","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/prefer_ts_expect_error.rs","lineNumber":13,"sourceCode":"use cow_utils::CowUtils;\nuse oxc_ast::Comment;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::{ContextHost, LintContext},\n    rule::Rule,\n};\n\nfn prefer_ts_expect_error_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Enforce using `@ts-expect-error` over `@ts-ignore`\")\n        .with_help(\"Use \\\"@ts-expect-error\\\" to ensure an error is actually being suppressed.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferTsExpectError;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce using @ts-expect-error over @ts-ignore.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// TypeScript allows you to suppress all errors on a line by placing a comment starting with @ts-ignore or @ts-expect-error immediately before the erroring line.\n    /// The two directives work the same, except @ts-expect-error causes a type error if placed before a line that's not erroring in the first place.\n    ///\n    /// This means it's easy for @ts-ignores to be forgotten about, and remain in code even after the error they were suppressing is fixed.","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/prefer_ts_expect_error.rs#L1-L31","documentation":"Lint diagnostic from typescript/prefer-ts-expect-error: a @ts-ignore comment was found. Unlike @ts-expect-error, @ts-ignore silently swallows errors even when the suppressed error no longer exists, so typos and stale suppressions go unnoticed.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/prefer_ts_expect_error.rs:13 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace @ts-ignore with @ts-expect-error so TypeScript errors if nothing is actually suppressed","Remove the comment entirely if the underlying error was fixed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}