oxc-project/oxc · warning · OxcDiagnostic
tslint comment detected: "{tslint_comment}"
Error message
tslint comment detected: "{tslint_comment}" What it means
Warning from typescript/ban-tslint-comment via ban_tslint_comment_diagnostic() (crates/oxc_linter/src/rules/typescript/ban_tslint_comment.rs:8). It flags any 'tslint:<flag>' comment (disable, enable, disable-next-line, ...). TSLint is deprecated, so these comments are inert leftovers that modern tooling cannot honor.
Source
Thrown at crates/oxc_linter/src/rules/typescript/ban_tslint_comment.rs:8
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{context::LintContext, rule::Rule};
fn ban_tslint_comment_diagnostic(tslint_comment: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("tslint comment detected: \"{tslint_comment}\"")).with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct BanTslintComment;
declare_oxc_lint!(
/// ### What it does
///
/// This rule disallows `tslint:<rule-flag>` comments.
///
/// ### Why is this bad?
///
/// Useful when migrating from TSLint to ESLint. Once TSLint has been
/// removed, this rule helps locate TSLint annotations
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:View on GitHub (pinned to e1e7af627c)
Solutions
- Delete the tslint comment if the suppression is no longer needed
- Replace it with the ESLint/oxlint equivalent: '// eslint-disable-next-line <rule> -- reason' when suppression is still required
- Run a repo-wide codemod (e.g. 'rg -l "tslint:" | xargs sed -i "/tslint:/d"' reviewed per file) so stragglers cannot reappear
- Enable ban-tslint-comment as error in CI so migrated files fail the build
Example fix
// before
// tslint:disable-next-line: no-console
console.log('debug');
// after
console.log('debug'); // eslint-disable-next-line no-console -- temporary debug trace Defensive patterns
Strategy: validation
Validate before calling
if (/\/\/\s*tslint:(disable|enable|next-line)/.test(source)) {
fail('file still contains tslint: comments');
} Type guard
function isTslintComment(comment: string): boolean {
return /tslint:(disable|enable|disable-next-line|no-disable)/.test(comment);
} Prevention
- Run the tslint-to-eslint codemod and verify with 'rg tslint:' before deleting the old config
- Keep ban-tslint-comment enabled in CI so remnants fail fast
- Never copy pragma comments from pre-2019 snippets without review
When it happens
Trigger: Any comment in the scanned file matching tslint: — e.g. '// tslint:disable-next-line: no-console' or '// tslint:enable' — regardless of whether an ESLint-compatible equivalent exists; the span labels the comment text.
Common situations: Migrating an Angular/pre-2019 project from TSLint to ESLint/oxlint where codemods missed file headers or rarely-touched files; copying old snippet code that still carries tslint pragmas.
Related errors
- encountered allocation error
- {error_message:?}
- Do not use @ts-{ts_comment_name} because it alters compilati
- Use "@ts-expect-error" instead of @ts-ignore, as "@ts-ignore
- Type can be trivially inferred from the initializer
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/40cf696afa5472f5.
Report an issue: GitHub.