← Back

no-unneeded-ternary warning

Disallows ternary operators when simpler alternatives exist

Examples

❌  Incorrect

const a = x === 2 ? true : false;
const b = x ? true : false;

✅  Correct

const foo = x === 2 ? 'yes' : 'No';
const bar = x !== false;
const baz = x ? 'Yes' : 'No';