unicorn/prefer-logical-operator-over-ternary Style
What it does
This rule finds ternary expressions that can be simplified to a logical operator.
Why is this bad?
Using a logical operator is shorter and simpler than a ternary expression.
Example
Examples of incorrect code for this rule:
javascript
const foo = bar ? bar : baz;
console.log(foo ? foo : bar);
Examples of correct code for this rule: const foo = bar || baz; console.log(foo ?? bar);
## How to use
To **enable** this rule in the CLI or using the config file, you can use:
::: code-group
```bash [CLI]
oxlint --deny unicorn/prefer-logical-operator-over-ternary
json
{
"rules": {
"unicorn/prefer-logical-operator-over-ternary": "error"
}
}
:::