Skip to content

[no-unused-expressions] no-unused-expressions works not as expected with optional chaining and condition #1764

Closed
@kkatsuba

Description

@kkatsuba

Repro

{
  "rules": {
    "no-unused-expressions": 0,
    "@typescript-eslint/no-unused-expressions": [2, {
      "allowShortCircuit": true
    }]
  }
}
const expr: any = false;
const v: { [key: string]: any } = {};
v.somestaff?.callMe(); // Works fine 👍
expr && v.somestaff?.callMe(); // Problem 😭

Expected Result
No error for line

Actual Result
image

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.23.0
@typescript-eslint/parser 2.23.0
TypeScript 3.7.5
ESLint 6.8.0
node 11.15.0
npm 6.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions