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

Small document improvements #1199

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions docs/rules/jsx-first-prop-new-line.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Prevent missing parentheses around multiline JSX (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>
);
```