Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add more examples for multiline-ternary #17610

Merged
merged 2 commits into from Oct 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 23 additions & 13 deletions docs/src/rules/multiline-ternary.md
Expand Up @@ -18,9 +18,14 @@ var foo = bar > baz ? value1 : value2;
The above can be rewritten as the following to improve readability and more clearly delineate the operands:

```js

var foo = bar > baz ?
value1 :
value2;

var foo = bar > baz
? value1
: value2;
```

## Rule Details
Expand Down Expand Up @@ -49,11 +54,8 @@ Examples of **incorrect** code for this rule with the `"always"` option:

foo > bar ? value1 : value2;

foo > bar ? value :
value2;

foo > bar ?
value : value2;
AshiotisCy marked this conversation as resolved.
Show resolved Hide resolved
foo > bar
? value : value2;
```

:::
Expand All @@ -69,11 +71,11 @@ foo > bar ?
value1 :
value2;

foo > bar ?
(baz > qux ?
value1 :
value2) :
value3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

foo > bar
? (baz > qux
? value1
: value2)
: value3;
```

:::
Expand Down Expand Up @@ -126,6 +128,12 @@ foo > bar &&
bar > baz ?
value1 :
value2;

foo > bar
? baz > qux
? value1
: value2
: value3;
```

:::
Expand Down Expand Up @@ -164,9 +172,11 @@ foo > bar ? value1 : value2;

foo > bar ? (baz > qux ? value1 : value2) : value3;

foo > bar ? (
baz > qux ? value1 : value2
) : value3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

foo > bar
? ( baz > qux
? value1
: value2 )
: value3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a "correct" example for "never".

Playground demo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I have removed it from the the "never" example

```

:::
Expand Down