Skip to content

eslint/no-ternary Style

What it does

Disallow ternary operators

Why is this bad?

The ternary operator is used to conditionally assign a value to a variable. Some believe that the use of ternary operators leads to unclear code.

Example

javascript
var foo = isBar ? baz : qux;

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-ternary
json
{
  "rules": {
    "no-ternary": "error"
  }
}

References

Released under the MIT License.