Skip to content

linter: no-unused-private-class-members false positive for awaited private field #21066

Description

@rotu

What version of Oxlint are you using?

1.58.0

What command did you run?

oxlint -D eslint/no-unused-private-class-members awaited-private-field.js

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

I am not using a config file for the minimal repro.

What happened?

Oxlint reports a private field as unused when it is only read through await.

Minimal repro:

class AwaitedPrivateField {
   #promise = Promise.resolve();

   async stop() {
      await this.#promise;
   }
}

Actual behavior:

eslint(no-unused-private-class-members): 'promise' is defined but never used.

Expected behavior:

No diagnostic. await this.#promise is a value read of the private field.

Related application shape:

class Stopper {
   #promise;

   async stop() {
      this.#promise ??= this.makePromise();
      await this.#promise;
   }

   makePromise() {
      return Promise.resolve();
   }
}

That shape is also flagged, but the smaller await this.#promise example reproduces the core issue by itself.

Additional context:

That suggests this is a remaining read-context gap for AwaitExpression, not a case already covered by the existing fixes.

Possible implementation direction:

is_value_context already recurses through AwaitExpression, but is_read currently falls through to false for the immediate PrivateFieldExpression -> AwaitExpression pair before that recursive value-context check can count it as a read.

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions