Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
Nokel81 committed Apr 1, 2022
1 parent 7440098 commit 91f25b7
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions docs/rules/jsx-tag-spacing.md
Expand Up @@ -62,7 +62,7 @@ Examples of **correct** code for this rule, when configured with `{ "closingSlas

### `beforeSelfClosing`

This check can be set to `"always"`, `"never"` or `"allow"` (to disable it).
This check can be set to `"always"`, `"never"`, `"multiline-always"`, or `"allow"` (to disable it).

If it is `"always"`, the check warns whenever a space is missing before the closing bracket. If `"never"` then it warns if a space is present before the closing bracket. The default value of this check is `"always"`.

Expand Down Expand Up @@ -102,6 +102,26 @@ Examples of **correct** code for this rule, when configured with `{ "beforeSelfC
/>
```

Examples of **incorrect** code for this rule, when configured with `{ "beforeSelfClosing": "multiline-always" }`:

```jsx
<Hello
firstName="John"
lastName="Smith" />
<Hello
firstName="John"
lastName="Smith"/>
```

Examples of **correct** code for this rule, when configured with `{ "beforeSelfClosing": "multiline-always" }`:

```jsx
<Hello
firstName="John"
lastName="Smith"
/>
```

### `afterOpening`

This check can be set to `"always"`, `"never"`, `"allow-multiline"` or `"allow"` (to disable it).
Expand Down Expand Up @@ -179,7 +199,7 @@ Examples of **correct** code for this rule, when configured with `{ "afterOpenin

### `beforeClosing`

This check can be set to `"always"`, `"never"`, or `"allow"` (to disable it).
This check can be set to `"always"`, `"never"`, `"multiline-always"`, or `"allow"` (to disable it).

If it is `"always"` the check warns whenever whitespace is missing before the closing bracket of a JSX opening element or whenever a space is missing before the closing bracket closing element. If `"never"`, then it warns if a space is present before the closing bracket of either a JSX opening element or closing element. This rule will never warn for self closing JSX elements. The default value of this check is `"allow"`.

Expand Down Expand Up @@ -219,6 +239,31 @@ Examples of **correct** code for this rule, when configured with `{ "beforeClosi
</Hello>
```

Examples of **incorrect** code for this rule, when configured with `{ "beforeClosing": "multiline-always" }`:

```jsx
<Hello
firstName="John"
lastName="Smith">
</Hello>
<Hello
firstName="John"
lastName="Smith" >
Goodbye
</Hello>
```

Examples of **correct** code for this rule, when configured with `{ "beforeClosing": "multiline-always" }`:

```jsx
<Hello
firstName="John"
lastName="Smith"
>
Goodbye
</Hello>
```

## When Not To Use It

You can turn this rule off if you are not concerned with the consistency of spacing in or around JSX brackets.

0 comments on commit 91f25b7

Please sign in to comment.