Skip to content

Enhancement: [prefer-optional-chain] Support simple equals expressions #7986

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
boris-petrov opened this issue Nov 24, 2023 · 1 comment
Closed
4 tasks done
Labels
duplicate This issue or pull request already exists enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@boris-petrov
Copy link

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/prefer-optional-chain/

Description

prefer-optional-chain could also support cases like the following:

if (this.foo != null && this.foo.bar === 1) {
}

This is probably a very common pattern and would be nice to be handled by the rule.

Fail

if (this.foo != null && this.foo.bar === 1) {
}

Pass

if (this.foo?.bar === 1) {
}

Additional Info

No response

@boris-petrov boris-petrov added enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Nov 24, 2023
@bradzacher
Copy link
Member

This would be covered by #7170

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look labels Nov 24, 2023
@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 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 enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants