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

Skip to content

Bug: @typescript-eslint/prefer-optional-chain should be smarter with AND && #6435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
dimaMachina opened this issue Feb 7, 2023 · 2 comments
Closed
4 tasks done
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@dimaMachina
Copy link

dimaMachina commented Feb 7, 2023

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.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&sourceType=module&code=DYUwLgBAZgliwBMAiIoC4IEMB2BPAUPjFBABQAOmATiNmAPwB02mAtiBAGSf4TRyIUJbr37xkqZmw4i+scUKnsIAQgC8aiAHIA+jrC5ytaVq485AiVCUd1m3ToDOAYwAWIVpi0BKCAG8IAF8gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WloHsalfkwCG8WmQAWo5uki9o-aJHBgAviHVA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

if (parent?.name &&
  fieldDef &&
  fieldDef.name &&
  fieldDef.name !== '__typename' &&
  fieldDef.name !== '__schema') {}

ESLint Config

{
  "rules": {
    "@typescript-eslint/prefer-optional-chain":"error"
  }
}

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

I expected fieldDef && fieldDef.name to replace by fieldDef?.name

Actual Result

no errors

Additional Info

No response

@dimaMachina dimaMachina added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 7, 2023
@bradzacher
Copy link
Member

Duplicate of #6332 (your own issue!) please use the search

@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed bug Something isn't working triage Waiting for team members to take a look labels Feb 7, 2023
@dimaMachina
Copy link
Author

yeah but it is another case with AND and not OR 😅

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants