Skip to content

oxlint(lsp): Auto-fix for unused eslint-disable directives should delete the line, not leave blank comments #21088

@arsnl

Description

@arsnl

Confirm that this is a Bug for the editor extension, not the CLI

  • This bug does not happen in the Oxlint/Oxfmt CLI
  • After restarting the editor, the bug still appears

Versions used

VS Code extension: v1.52.0
oxlint: v1.58.0
oxfmt: v0.43.0
VS Code version: 1.105.1
Operating System and Version: macOs 26.3.1
Node Version: v24.12.0
Node Manager: npm v11.6.2

What happened?

When Oxlint reports an unused disable directive (e.g. with reportUnusedDisableDirectives enabled in the Oxlint config), the CLI does not offer an auto-fix for that diagnostic. The VS Code extension does apply a fix (e.g. via Fix all / source.fixAll.oxc on save), but the fix is wrong: it strips the directive text and leaves an empty comment on the line (// or /**/) instead of removing the whole line, which matches what users expect from ESLint-style tooling and leaves noisy, useless lines in the file.

Steps to reproduce

  1. Clone https://github.com/arsnl/oxlint-repro-file-level-disable and open the folder in VS Code.
  2. Run npm install.
  3. In .vscode/settings.json, set "source.fixAll.oxc" to "always" under editor.codeActionsOnSave (or use Fix all from the lightbulb on an unused-disable diagnostic).
  4. Save test.ts (or trigger fix all).
    Actual behavior: Lines that contained only the disable comment become // or /**/ with nothing after it.

Expected behavior: The entire line should be removed when nothing meaningful remains (same idea as removing a full eslint-disable line), not replaced with an empty comment token.
(Related upstream context: in that repro, file-level oxlint-disable for a file-scope rule may still leave the real rule violation plus an “unused directive” warning—that’s separate Oxlint engine behavior; this ticket is specifically about the editor fix leaving empty comments.)

Reproduction repo

https://github.com/arsnl/oxlint-repro-file-level-disable

Minimal workspace: test.ts, oxlint.config.ts (reportUnusedDisableDirectives: "warn"), and .vscode/ recommendations for oxc.oxc-vscode. See the “Reproduction (VS Code extension)” section in the repo README.md.

Output channel log

Click to expand
2026-04-05 14:42:48.027 [info] [Error - 14:42:48] Server process exited with code 0.
2026-04-05 14:42:48.028 [info] [Trace - 14:42:48] Received request 'client/registerCapability - (0)'.
2026-04-05 14:42:48.028 [info] Params: {
    "registrations": [
        {
            "id": "watcher-formatter-file:///Users/arsnl/Developer/oxlint-repro-file-level-disable",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": {
                            "baseUri": "file:///Users/arsnl/Developer/oxlint-repro-file-level-disable",
                            "pattern": ".oxfmtrc.json"
                        },
                        "kind": 7
                    },
                    {
                        "globPattern": {
                            "baseUri": "file:///Users/arsnl/Developer/oxlint-repro-file-level-disable",
                            "pattern": ".oxfmtrc.jsonc"
                        },
                        "kind": 7
                    },
                    {
                        "globPattern": {
                            "baseUri": "file:///Users/arsnl/Developer/oxlint-repro-file-level-disable",
                            "pattern": "oxfmt.config.ts"
                        },
                        "kind": 7
                    },
                    {
                        "globPattern": {
                            "baseUri": "file:///Users/arsnl/Developer/oxlint-repro-file-level-disable",
                            "pattern": "vite.config.ts"
                        },
                        "kind": 7
                    },
                    {
                        "globPattern": {
                            "baseUri": "file:///Users/arsnl/Developer/oxlint-repro-file-level-disable",
                            "pattern": ".editorconfig"
                        },
                        "kind": 7
                    }
                ]
            }
        }
    ]
}


2026-04-05 14:42:48.028 [info] [Trace - 14:42:48] Sending response 'client/registerCapability - (0)'. Processing request took 0ms
2026-04-05 14:42:48.028 [info] No result returned.


2026-04-05 14:43:18.904 [info] [Trace - 14:43:18] Sending notification 'textDocument/didChange'.
2026-04-05 14:43:18.904 [info] Params: {
    "textDocument": {
        "uri": "file:///Users/arsnl/Developer/oxlint-repro-file-level-disable/test.ts",
        "version": 3
    },
    "contentChanges": [
        {
            "text": "/**/\n\n//\nvar x = \"y\";"
        }
    ]
}

Metadata

Metadata

Assignees

Labels

A-editorArea - Editor and Language ServerA-linterArea - Linter

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions