Skip to content

linter: possible false positive in no-unused-var when parameter is only used as a type predicate #22367

@uhyo

Description

@uhyo

What version of Oxlint are you using?

1.64.0

What command did you run?

oxlint

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

Reproduces without a config file (requires no-unused-var to be enabled)

What happened?

Code:

export function foo(a: unknown): a is string {
  return true;
}

oxlint flags a as unused despite its use in return type (a is string).

Error message
  ⚠ eslint(no-unused-vars): Parameter 'a' is declared but never used. Unused parameters should start with a '_'.
   ╭─[test.ts:2:21]
 1 │ 
 2 │ export function foo(a: unknown): a is string {
   ·                     ┬
   ·                     ╰── 'a' is declared here
 3 │   return true;
   ╰────
  help: Consider removing this parameter.

I am not sure if this should be treated as a bug; it's totally understandable to flag a as unused particularly because you can't write meaningful code without using such a parameter inside function body.

I'm reporting this anyway because it diverges from ESLint behavior and I encountered this while migrating from ESLint.

Thank you for the great tool. It's fast 🙂

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