Skip to content

linter: no-unused-vars false positives when variable and type have same name #8236

@EYHN

Description

@EYHN

What version of Oxlint are you using?

0.15.5

What command did you run?

oxlint

What does your .oxlint.json config file look like?

without config file

What happened?

with typescript file:

// bad.ts
const a = {
  hello: "world",
};

export type a = typeof a;

it shows error when i run oxlint

  × eslint(no-unused-vars): Type alias 'a' is declared but never used. Unused type aliases should start with a '_'.
   ╭─[src\bad.ts:1:7]
 1 │ const a = {
   ·       ┬
   ·       ╰── 'a' is declared here
 2 │   hello: "world",
   ╰────
  help: Consider removing this declaration.

But when I rewrite type a to type b

// good.ts
const a = {
  hello: "world",
};

export type b = typeof a;

no error will show

Found 0 warnings and 0 errors.

It seems that oxlint cannot correctly handle the situation where the variable and type with the same name. but this code can pass in eslint. so I think it's a bug

Metadata

Metadata

Assignees

Labels

A-linterArea - LinterC-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions