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

  1. Delete the tslint comment if the suppression is no longer needed
  2. Replace it with the ESLint/oxlint equivalent: '// eslint-disable-next-line <rule> -- reason' when suppression is still required
  3. Run a repo-wide codemod (e.g. 'rg -l "tslint:" | xargs sed -i "/tslint:/d"' reviewed per file) so stragglers cannot reappear
  4. 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

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


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/40cf696afa5472f5. Report an issue: GitHub.