15.6Comparison Operators & Equality / No Nested Ternaries

ネストした三項演算子は避ける

三項演算子はネストさせず、一般的に単一行の式にします。

ネストした三項演算子は、コードのロジックを追うのを非常に困難にし、可読性を著しく低下させます。条件が複雑になる場合は、`if/else` 文を使うか、ロジックを複数の変数や関数に分割することで、コードをよりシンプルで理解しやすいものに保つべきです。

❌ Bad
// bad
const foo = maybe1 > maybe2
  ? "bar"
  : value1 > value2 ? "baz" : null;
✅ Good
// better
const maybeNull = value1 > value2 ? 'baz' : null;
const foo = maybe1 > maybe2
  ? 'bar'
  : maybeNull;