Skip to content

Commit

Permalink
Update docs in accordance with the new option set
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed May 12, 2019
1 parent bcb79d8 commit 9266330
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions docs/rules/jsx-curly-newline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,32 @@ This rule enforces consistent linebreaks inside of curlies of jsx curly expressi

## Rule Options

This rule has a string option:
This rule accepts either an object option:

```ts
{
multiline: "consistent" | "forbid" | "require", // default to 'consistent'
singleline: "consistent" | "forbid" | "require", // default to 'consistent'
}
```
Option `multiline` takes effect when the jsx expression inside the curlies occupies multiple lines.

Option `singleline` takes effect when the jsx expression inside the curlies occupies a single line.

* `consistent` enforces either both of linebreaks around curlies are present, or none are present.
* `multiline` enforces that when the contained expression spans multiple line, require both linebreaks. When the contained expression is single line, disallow both line breaks.
* `multiline-lax` (default) enforces that when the contained expression spans multiple line, require both linebreaks. When the contained expression is single line, disallow inconsistent line break.
* `forbid` disallows linebreaks around curlies.
* `require` enforces the presence of linebreaks aounrd curlies.

or a string option:

* `consistent` (default) is an alias for `{ multiline: "consistent", singleline: "consistent" }`.
* `never` is an alias for `{ multiline: "forbid", singleline: "forbid" }`

### consistent
or an

When `consistent` is set, the following patterns are considered warnings:
### consistent (default)

When `consistent` or `{ multiline: "consistent", singleline: "consistent" }` is set, the following patterns are considered warnings:

```jsx
<div>
Expand All @@ -30,6 +47,12 @@ When `consistent` is set, the following patterns are considered warnings:
{
foo }
</div>

<div>
{ foo &&
foo.bar
}
</div>
```

The following patterns are **not** warnings:
Expand All @@ -46,18 +69,20 @@ The following patterns are **not** warnings:
</div>
```

### multiline
### never

When `multiline` is set, the following patterns are considered warnings:
When `never` or `{ multiline: "forbid", singleline: "forbid" }` is set, the following patterns are considered warnings:

```jsx
<div>
{ foo &&
foo.bar }
{
foo &&
foo.bar
}
</div>

<div>
{
{
foo
}
</div>
Expand All @@ -72,32 +97,35 @@ The following patterns are **not** warnings:

```jsx
<div>
{
foo &&
foo.bar
}
{ foo &&
foo.bar }
</div>

<div>
{ foo }
</div>
```

### multiline-lax
## require

When `multiline-lax` (default) is set, the following patterns are considered warnings:
When `{ multiline: "require", singleline: "require" }` is set, the following patterns are considered warnings:

```jsx
<div>
{ foo &&
foo.bar }
</div>

<div>
{ foo }
</div>

<div>
{ foo
}
</div>
```

The following patterns are **not** warnings:

```jsx
Expand All @@ -109,17 +137,13 @@ The following patterns are **not** warnings:
</div>

<div>
{
{
foo
}
</div>

<div>
{ foo }
</div>

```


## When Not To Use It

You can turn this rule off if you are not concerned with the consistency around the linebreaks inside of JSX attributes or expressions.

0 comments on commit 9266330

Please sign in to comment.