Skip to content

Commit

Permalink
Merge pull request #1199 from preco21/docs-improvement
Browse files Browse the repository at this point in the history
Small document improvements
  • Loading branch information
ljharb committed May 16, 2017
2 parents ecc327a + 859d12a commit 2d17b7f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 11 deletions.
5 changes: 3 additions & 2 deletions docs/rules/jsx-first-prop-new-line.md
Expand Up @@ -6,11 +6,12 @@ Ensure correct position of the first property.

## Rule Details

This rule checks whether the first property of all JSX elements is correctly placed. There are three possible configurations:
This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations:

* `always`: The first property should always be placed on a new line.
* `never` : The first property should never be placed on a new line, e.g. should always be on the same line as the Component opening tag.
* `multiline`: The first property should always be placed on a new line when the JSX tag takes up multiple lines.
* `multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties. `default`
* `multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties. This is the `default` value.

The following patterns are considered warnings when configured `"always"`:

Expand Down
87 changes: 78 additions & 9 deletions docs/rules/jsx-wrap-multilines.md
@@ -1,11 +1,20 @@
# Prevent missing parentheses around multiline JSX (react/jsx-wrap-multilines)

Wrapping multiline JSX in parentheses can improve readability and/or convenience. It optionally takes a second parameter in the form of an object, containing places to apply the rule. By default, `"declaration"`, `"assignment"`, `"return"`, and `"arrow"` syntax is checked, but these can be explicitly disabled. Any syntax type missing in the object will follow the default behavior (become enabled).
Wrapping multiline JSX in parentheses can improve readability and/or convenience.

**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.

## Rule Details

This rule optionally takes a second parameter in the form of an object, containing places to apply the rule. By default, all the syntax listed below will be checked, but these can be explicitly disabled. Any syntax type missing in the object will follow the default behavior (become enabled).

There are the possible syntax available:

* `declaration`
* `assignment`
* `return`
* `arrow`

The following patterns are considered warnings:

```jsx
Expand All @@ -32,20 +41,80 @@ var Hello = createReactClass({
);
}
});
```

The following patterns are considered warnings when configured `{declaration: true}`.

```jsx
var hello = <div>
<p>Hello</p>
</div>;
```

// When [1, {declaration: false}]
The following patterns are not considered warnings when configured `{declaration: true}`.

```jsx
var hello = (
<div>
<p>Hello</p>
</div>
);
```

The following patterns are considered warnings when configured `{assignment: true}`.

```jsx
var hello;
hello = <div>
<p>Hello</p>
</div>
</div>;
```

// When [1, {declaration: true, assignment: false, return: true}]
var world = <div>
<p>World</p>
</div>
The following patterns are not considered warnings when configured `{assignment: true}`.

// When [1, {arrow: false}]
```jsx
var hello;
hello = (
<div>
<p>Hello</p>
</div>
);
```
The following patterns are considered warnings when configured `{return: true}`.

```jsx
function hello() {
return <div>
<p>Hello</p>
</div>;
}
```

The following patterns are not considered warnings when configured `{return: true}`.

```jsx
function hello() {
return (
<div>
<p>Hello</p>
</div>
);
}
```
The following patterns are considered warnings when configured `{arrow: true}`.

```jsx
var hello = () => <div>
<p>World</p>
</div>
</div>;
```

The following patterns are not considered warnings when configured `{arrow: true}`.

```jsx
var hello = () => (
<div>
<p>World</p>
</div>
);
```

0 comments on commit 2d17b7f

Please sign in to comment.