Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: enable an eslint rule, @typescript-eslint/strict-boolean-expressions #633

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

0b5vr
Copy link
Contributor

@0b5vr 0b5vr commented Feb 19, 2021

Sequel of #292

lintに危なげなboolean expressionsを起こってくれるルールを追加しました。

レビューの際は、以下のメリデメ吟味して良さそうか悪そうか判断いただければ幸いです。

pros

  • 0 の誤falsyがあり得る number | undefined の使用を禁止してくれます
    • "" も同様
    • 唯一のメリットですが、恩恵は大きいと思っています

cons

  • Array index accessingを行い、それのnullチェックをしていた箇所が全部「このifは必要ない」と怒られます
    • type assertionを使い無理やり対処しています。若干本末転倒気味です
  • すべての boolean | undefined が怒られるのは若干うるさいか?
    • たくさんの boolean | undefined の後ろに ?? false が付きました
  • Union typeのstringに対しても "" の確認をさせられるのは少しうるさいです

@0b5vr 0b5vr added the Refactor Cool code is cool label Feb 19, 2021
@0b5vr 0b5vr self-assigned this Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Cool code is cool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant