Rule: prefer-conditional-expression

Recommends to use a conditional expression instead of assigning to the same thing in each branch of an if statement.

Rationale

This reduces duplication and can eliminate an unnecessary variable declaration.

Config

If check-else-if is specified, the rule also checks nested if-else-if statements.

Examples
"prefer-conditional-expression": true
"prefer-conditional-expression": [true, "check-else-if"]
Schema
{
  "type": "string",
  "enum": [
    "check-else-if"
  ]
}