Skip to content

linter: disable directives fail when trailing explanations are applied #22152

@camc314

Description

@camc314

Summary

Disable directives can stop suppressing diagnostics when an explanation is added after the rule name. In the latest commit, several comments had to be changed from:

// oxlint-disable-next-line typescript/unbound-method - bound in `runHook`

to:

// oxlint-disable-next-line typescript/unbound-method

because the trailing explanation caused the directive to no longer match typescript/unbound-method.

Reproduction

class C {
  method() {}
}

const c = new C();

// oxlint-disable-next-line typescript/unbound-method - bound later
const method = c.method;

Run:

oxlint --type-aware --type-check -D typescript/unbound-method repro.ts

Expected Behavior

The directive should suppress typescript/unbound-method, or oxlint should clearly document and/or diagnose unsupported trailing explanation syntax.

ESLint-style descriptions commonly use --, for example:

// oxlint-disable-next-line typescript/unbound-method -- bound later
const method = c.method;

That form should continue to work consistently across Rust linting, JS plugin APIs, unused-disable reporting, and autofixes.

Actual Behavior

With a trailing single-hyphen explanation, oxlint treats the explanation as part of the rule name, so the disabled rule becomes something like:

typescript/unbound-method - bound later

That does not match the emitted typescript/unbound-method diagnostic, so the warning/error is still reported.

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