Skip to content

linter: "allow" for reportUnusuedDisableDirectives via LSP returns warnings #22713

@RioShopfront

Description

@RioShopfront

What version of Oxlint are you using?

1.61.0

What command did you run?

LSP plugin configuration (Intellij or VSCode to their "allow" setting")

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

import { defineConfig } from "oxlint";

export default defineConfig({
    options: {
        typeAware: true,
        typeCheck: true,
        reportUnusedDisableDirectives: "allow", // or "off"
    },
});

What happened?

Both VSCode and Intellij plugins allow the choice of "allow" for these unused directives. VSCode allows a null choice which nicely means the issue can be avoided.

The VSCode plugin will send the below params as part of its workspace/didChangeConfiguration notification

"options": {
    "unusedDisableDirectives": "allow",
    "typeAware": true,
    "disableNestedConfig": false,
    "run": "onType",
    "flags": {
        "disable_nested_config": "false"
    }
}

When "allow" is used the LSP returns warnings on unused directives such as.

// oxlint-disable @typescript-eslint/naming-convention
export class CorrectlyNamedError extends Error {}

This becomes a problem as the automatic fixing or removing the unused directives is not expected while using "allow" - and while separate to the issue I am experiencing some rules not showing up in the LSP but will via the CLI, so I don't want the LSP stepping in and removing "used" directives.

The default value was changed to None in 50359dc while still enabling the LSP configuration to step over a config file's "deny" with an "allow"

I think that either the server_linter.rs's lint_path should skip out early since the severity while using "allow" is now not None, or the create_unused_directives_report should be modified to handle the Allow branch of its severity: AllowWarnDeny,.

Perhaps Allow should be treated like Hint/Information Severity (provided automatic fixes through the LSP wouldn't clear the unused directives)

Metadata

Metadata

Assignees

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