Prefer nullish coalescing
🌟 What is the purpose of this PR?
This introduces an eslint rule to prefer ?? over || when not using booleans.
🔗 Related links
- Asana Task (internal)
🚫 Blocked by
N/A
🔍 What does this change?
- Introduce eslint rule to prefer
??over||when not using booleans – this forces us to be intentional about handling "falsey" values and can prevent some subtle bugs - Fix errors where simple to do so without changing behaviour
- Add temporary lint rule disable comments for most existing errors to reduce change of this PR breaking stuff – can slowly improve existing problems as we touch that come
📜 Does this require a change to the docs?
N/A
⚠️ Known issues
N/A
🐾 Next steps
- Remove all existing uses of
||when??is more appropriate - this will be done slowly instead of one big bang – so it can be done when the intention is known
🛡 What tests cover this?
Playwright tests
@CiaranMn to clarify, this is not the same as #916. We delayed this because that changed code, and we weren't certain it didn't introduce bugs, whereas in 99% of cases here I've added ignore comments (which is the strategy I was arguing for in #916).
I've exempted the backend packages from this now, so will just review any remaining comments & hopefully we can get this merge
@nathggns WDYT of marking this PR as draft till dev-graph is merged into main? Not sure we should finish this PR till then to avoid extra work.
@kachkaev dev graph packages are exempted, as requested by @CiaranMn https://github.com/hashintel/hash/pull/1005#pullrequestreview-1089938443