Skip to content

linter: no-unused-private-class-members reports false positive for switch discriminant #20302

@zhen-wei

Description

@zhen-wei

What version of Oxlint are you using?

1.55.0

What command did you run?

oxlint -c oxlint.config.ts

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

import { defineConfig } from 'oxlint';

export default defineConfig({
    plugins: ['eslint'],
    rules: {
        'no-unused-private-class-members': 'error'
    },
});

What happened?

no-unused-private-class-members reports a false positive when a private field is only read inside a switch discriminant.

class Example {
  #value = 1;
  check() {
    switch (this.#value) {
      case 1:
        console.log("one");
        break;
      default:
        console.log("other");
    }
  }
}

In this case, #value is actually used as the switch discriminant, but the rule still reports it as unused.

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