Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ fn is_value_context(kind: &AstNode, semantic: &Semantic<'_>) -> bool {
| AstKind::TSInstantiationExpression(_)
| AstKind::TSNonNullExpression(_)
| AstKind::TSTypeAssertion(_)
| AstKind::UpdateExpression(_) => {
| AstKind::UpdateExpression(_)
| AstKind::AwaitExpression(_) => {
is_value_context(semantic.nodes().parent_node(kind.id()), semantic)
}

Expand Down Expand Up @@ -452,6 +453,7 @@ fn test() {
r"class C { #field = 1; static { const obj = new C(); console.log(obj.#field); } }",
r"class C { #method() { return 42; } static { const obj = new C(); obj.#method(); } }",
r"class C { #field = 1; static { const getField = obj => { return obj.#field; }; } }",
r"export class Database<const S extends idb.DBSchema> { readonly #db: Promise<idb.IDBPDatabase<S>>; constructor(name: string, version: number, hooks: idb.OpenDBCallbacks<S>) { this.#db = idb.openDB<S>(name, version, hooks); } async read() { let db = await this.#db; } }",
];

let fail = vec![
Expand Down Expand Up @@ -597,6 +599,7 @@ fn test() {
}
}
}",
r"class Foo { #awaitedMember; async method() { await this.#awaitedMember; } }",
];

Tester::new(NoUnusedPrivateClassMembers::NAME, NoUnusedPrivateClassMembers::PLUGIN, pass, fail)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,9 @@ source: crates/oxc_linter/src/tester.rs
· ──────────────────────────────
3 │
╰────

⚠ eslint(no-unused-private-class-members): 'awaitedMember' is defined but never used.
╭─[no_unused_private_class_members.tsx:1:13]
1 │ class Foo { #awaitedMember; async method() { await this.#awaitedMember; } }
· ──────────────
╰────
Loading