Skip to content

Commit

Permalink
Docs: fix docs for no-unneeded-ternary (fixes #12098)
Browse files Browse the repository at this point in the history
  • Loading branch information
samrae7 committed Oct 12, 2019
1 parent e5637ba commit fc6ee97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/rules/no-unneeded-ternary.md
Expand Up @@ -41,8 +41,6 @@ Examples of **incorrect** code for this rule:
var a = x === 2 ? true : false;

var a = x ? true : false;

var a = f(x ? x : 1);
```

Examples of **correct** code for this rule:
Expand All @@ -58,7 +56,7 @@ var a = x ? "Yes" : "No";

var a = x ? y : x;

var a = x ? x : 1; // Note that this is only allowed as it on the right hand side of an assignment; this type of ternary is disallowed everywhere else. See defaultAssignment option below for more details.
var a = x ? x : 1; // Note that this is only allowed when defaultAssignment option is set to true (which it is by default). See option details below.
```

## Options
Expand All @@ -70,14 +68,16 @@ This rule has an object option:

### defaultAssignment

The defaultAssignment option allows expressions of the form `x ? x : expr` (where `x` is any identifier and `expr` is any expression) as the right hand side of assignments (but nowhere else).
The defaultAssignment option allows expressions of the form `x ? x : expr` (where `x` is any identifier and `expr` is any expression).

Examples of additional **incorrect** code for this rule with the `{ "defaultAssignment": false }` option:

```js
/*eslint no-unneeded-ternary: ["error", { "defaultAssignment": false }]*/

var a = x ? x : 1;

f(x ? x : 1);
```

## When Not To Use It
Expand Down

0 comments on commit fc6ee97

Please sign in to comment.