Skip to content

linter: file-level inline disable comments do not suppress file-scope rules #21072

@arsnl

Description

@arsnl

What version of Oxlint are you using?

1.58.0

What command did you run?

oxlint

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

import { defineConfig } from "oxlint";

export default defineConfig({
  /* disable all categories so that we can enable rules selectively */
  categories: {
    correctness: "off",
    nursery: "off",
    pedantic: "off",
    perf: "off",
    restriction: "off",
    style: "off",
    suspicious: "off",
  },
  plugins: ["import"],
  rules: {
    "import/unambiguous": "error"
  },
  options: {
    reportUnusedDisableDirectives: "warn"
  },
});

What happened?

File-level inline disable comments (e.g. /* oxlint-disable rule-id */ at the top of a file) do not suppress file-level rules the way ESLint’s eslint-disable does for comparable rules (e.g. import/unambiguous, unicorn/filename-case). As a result:

  1. The underlying rule still reports diagnostics.
  2. With reportUnusedDisableDirectives enabled, Oxlint treats those disable comments as unused and reports something like "Unused eslint-disable directive (no problems were reported.)" even though the developer added the comment specifically to silence a file-scope violation.

Separately, the Oxlint VS Code extension (oxc.oxc-vscode) can apply a “fix” for unused-disable directives, but it leaves an empty comment (// or /**/) instead of removing the line, which is inconsistent with typical ESLint behavior and leaves noise in the file.

A minimal reproduction is available at https://github.com/arsnl/oxlint-repro-file-level-disable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions