holic / web3-scaffold

Quickly get up and running on web3
148 stars 19 forks source link

Enforce jsx conditional style to disallow `&&` use #29

Open davisshaver opened 2 years ago

davisshaver commented 2 years ago

See convo here: https://github.com/holic/web3-scaffold/pull/26#discussion_r906902085

It doesn't look like there's an existing eslint rule for this, but there's some code here which we may be able to incorporate as a custom rule: https://github.com/jsx-eslint/eslint-plugin-react/pull/2888

For more on why we want to avoid this pattern, see here: https://kentcdodds.com/blog/use-ternaries-rather-than-and-and-in-jsx

jamiew commented 2 years ago

Oh man I always wondered why ternary was preferred to &&. Nice one for wtfjs

holic commented 2 years ago

Got an old coworker to send me the lint rule/fix + tests! Will see about publishing a plugin that we can pull in here.