Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rule: "@typescript-eslint/prefer-optional-chain" fails with "Error: Unexpected member object type: TSNonNullExpression" #5553

Closed
@B4nan

Description

@B4nan

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

Latest version fails to process the MikroORM codebase. You can see the failed build in CI here:

https://github.com/mikro-orm/mikro-orm/runs/8041169217?check_suite_focus=true

There are more dependency updates, but the error was there even before, when it was only about eslint - I did verify it locally too, by only updating eslint.

$ eslint packages/**/*.ts

Oops! Something went wrong! :(

ESLint: 8.22.0

Error: Unexpected member object type: TSNonNullExpression
Occurred while linting /home/runner/work/mikro-orm/mikro-orm/packages/core/src/EntityManager.ts:1104
Rule: "@typescript-eslint/prefer-optional-chain"
    at getMemberExpressionText (/home/runner/work/mikro-orm/mikro-orm/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-optional-chain.js:284:27)
    at getText (/home/runner/work/mikro-orm/mikro-orm/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-optional-chain.js:2[6](https://github.com/mikro-orm/mikro-orm/runs/8041169217?check_suite_focus=true#step:8:7)3:20)
    at LogicalExpression[operator="||"] > UnaryExpression[operator="!"] > Identifier,LogicalExpression[operator="||"] > UnaryExpression[operator="!"] > MemberExpression,LogicalExpression[operator="||"] > UnaryExpression[operator="!"] > ChainExpression > MemberExpression (/home/runner/work/mikro-orm/mikro-orm/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-optional-chain.js:12[7](https://github.com/mikro-orm/mikro-orm/runs/8041169217?check_suite_focus=true#step:8:8):40)
    at ruleErrorHandler (/home/runner/work/mikro-orm/mikro-orm/node_modules/eslint/lib/linter/linter.js:1114:2[8](https://github.com/mikro-orm/mikro-orm/runs/8041169217?check_suite_focus=true#step:8:9))
    at /home/runner/work/mikro-orm/mikro-orm/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/runner/work/mikro-orm/mikro-orm/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/runner/work/mikro-orm/mikro-orm/node_modules/eslint/lib/linter/node-event-generator.js:2[9](https://github.com/mikro-orm/mikro-orm/runs/8041169217?check_suite_focus=true#step:8:10)7:26)
    at NodeEventGenerator.applySelectors (/home/runner/work/mikro-orm/mikro-orm/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/home/runner/work/mikro-orm/mikro-orm/node_modules/eslint/lib/linter/node-event-generator.js:340:[14](https://github.com/mikro-orm/mikro-orm/runs/8041169217?check_suite_focus=true#step:8:15))
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The line where it fails is here:

https://github.com/mikro-orm/mikro-orm/blob/40f725e851d0217fb1a3022492f72bcdad331e26/packages/core/src/EntityManager.ts#L1104

Reproduction Repository Link

https://github.com/mikro-orm/mikro-orm

Repro Steps

  1. clone the repo
  2. update eslint to latest version in the root package.json
  3. yarn install
  4. yarn lint

Versions

package version
@typescript-eslint/eslint-plugin 5.35.1
@typescript-eslint/parser 5.35.1
@typescript-eslint/scope-manager 5.35.1
@typescript-eslint/typescript-estree 5.35.1
@typescript-eslint/type-utils 5.35.1
@typescript-eslint/utils 5.35.1
TypeScript 4.7 & 4.8
ESLint 8.22.0
node 16.16 & 18.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething 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