-
-
Notifications
You must be signed in to change notification settings - Fork 944
linter: no-unused-private-class-members reported even though it's used in an expression #19989
Copy link
Copy link
Closed
Bug
Copy link
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.51.0
What command did you run?
oxlint
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
no config
What happened?
If a member #flag is used in an expression like this.#flag && console.log('spam');, that correctly reports no-unused-expressions but also incorrectly reports no-unused-private-class-members on #flag.
If we fixed no-unused-expressions, the no-unused-private-class-members would also disappear, but we're disabling no-unused-expressions since it's an old codebase with ~1k instances of that and we're used to that pattern.
More elaborate demonstration:
class Ok {
#flag = false; // ok
foo() {
if (this.#flag) console.log('spam'); // ok
}
baz() {
const x = false; // ok, does not report no-unused-var
x && console.log('foo'); // ok, reports no-unused-expressions
}
}
class Bug {
#flag = false; // bug: reports no-unused-private-class-members
foo() {
this.#flag && console.log('spam'); // ok, reports no-unused-expressions
}
}
export {Bug, Ok}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
Type
Fields
Give feedbackPriority
None yet
Effort
None yet