Let's consider these scenarios:
const obj = {};
obj ?? {};
obj?.prop;
It seems like both the nullish coalesce and optional chaining were not needed in these cases. Is there an Eslint rule that can identify and prevent such occurrences?
A bug recently surfaced where I mistakenly wrote newVal === val ?? defaultVal
instead of newVal === (val ?? defaultVal)
. This resulted in boolean ?? defaultVal
being evaluated. I believe no other Eslint rules can detect this issue, so perhaps utilizing something like no-unnecessary-condition could help avoid similar mistakes in the future.