Enable `@typescript-eslint/no-unnecessary-condition`
🌟 What is the purpose of this PR?
When reviewing #899, I noticed one case of unnecessary condition spotted by LGTM. It turned out a corresponding ESLint rule was not enabled. This PR fixes this issue and helps devs get earlier feedback on the code they write.
🔗 Related links
- Asana task (internal)
🔍 What does this change?
@typescript-eslint/no-unnecessary-conditionis introduced throughout the codebase
⚠️ Known issues
-
This PR may cause crashes short term because some ‘unnecessary’ conditions may be ‘necessary’. If this happens, we need to fix the typings first and only then re-introduce the conditions.
-
I added
eslint-ignorein a couple of places, mainly because ofawaitin loops (see https://github.com/typescript-eslint/typescript-eslint/issues/1459#issuecomment-614174852)
🐾 Next steps
- Fix bugs if any
🛡 What tests cover this?
- Playwright
- Manual
- https://github.com/blockprotocol/blockprotocol/pull/505
❓ How to test this?
- Checkout the branch / view the deployment
- Run HASH and click around
- Check Preview deployment in https://github.com/blockprotocol/blockprotocol/pull/505
This pull request fixes 1 alert when merging e7130873571281388bc2103eee25c752b8cb49ab into 018d3a12a4aff61644e6374803211b83139c0b48 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 2d53d1053dd65f229c09216f94bc7353f86ac8da into 51b4a8e86c01c7853c4d96fd0365a4c7a2116481 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 9a06aad9e06dd432a028579e2fbf1f4b8cd7e4e5 into 51b4a8e86c01c7853c4d96fd0365a4c7a2116481 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 8b6f8eb262beb39b98b4a8660f339ad0d37757ee into 2a7ca14837599a33c040b33a50cbee3e5fcf4dc4 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 8341c2ec2226309274f3f0110e36b4d1a42b5b8a into 2a7ca14837599a33c040b33a50cbee3e5fcf4dc4 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 02c9d3a4f2aa58d9adea593ddc1d882a37eaaf1e into 2beb700e8453dbb0752a2bed712114d0a38f71ef - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging f8475996e279392e2df2c011bcdeaf2133b7e7ce into 2beb700e8453dbb0752a2bed712114d0a38f71ef - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 83e0f91521091564296323f4c38353730c770821 into 8d22420f7b8e467eba13edb174a4b43599837d68 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging a0f1c6871986563626753be060214f396ca6dc26 into 1054c4b254fdeb99147a13da1a1543e158eb11a5 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging f16da1cc35da75292490c1f2027a895d6b7f16c5 into b112770850ed01510c15bc6e2b173b82602d2aab - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging ebd40fdb3ff1b364d782b6ff069074a83af92bd7 into 8c50ad1a7189feafe616827ec55b0391c0428a6f - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
Looking at this now
This pull request fixes 1 alert when merging 84b1e6d4d7fa504b07a911008c60a64c24e8e95f into 83a563df3e09afbaac858ef0dbe34cf3d298697f - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
This pull request fixes 1 alert when merging 3f618eeb8c1d8055715f6d4c228b5ece75701b06 into 7671483736b0089277712b7799251874bcc61727 - view on LGTM.com
fixed alerts:
- 1 for Useless conditional
Postponing at least till dev/graph is merged
Postponing at least till
dev/graphis merged
@kachkaev We may be able to pick this back up soon; lmk thoughts re: relative priority.
lmk thoughts re: relative priority.
This PR is quite big and hard to review, so let's abandon it. What I suggest doing instead is:
- Improve ESLint setup in the repo (cleanup shared config, configure Turborepo, etc.)
- Create a series of small PR which add this rule to different parts of the repo (small groups of yarn workspaces).
With this ‘one byte at a time’ approach we can ease the review process and also reduce the risk of new bugs. If we accidentally break something, it'll be easier to bisect and find the cause.