[prefer-optional-chain] Suggest (foo || {}).bar
as a valid match for the rule
#4395
Closed
3 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Repro
Expected Result
The rule should suggest to use optional chaining
I'm working on a codebase that uses this pattern a lot (about ~60% of the cases I refactor to optional chaining arise from this pattern, the others come from
&&
s) and I'm only getting prompted for the&&
cases.I expect to get the same warnings/errors/suggestions the
&&
case have, not including function callsActual Result
No error or warning
Additional Info
Willing to add a PR if needed
Tested this already against existing code in this repo
Versions
@typescript-eslint/eslint-plugin
5.9.0
@typescript-eslint/parser
5.9.0
TypeScript
4.5.5
ESLint
8.1.0
node
14.17.5
The text was updated successfully, but these errors were encountered: