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

Add some docs for jsx-child-element-spacing #1665

Merged
merged 1 commit into from Jan 31, 2018
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
45 changes: 45 additions & 0 deletions docs/rules/jsx-child-element-spacing.md
@@ -0,0 +1,45 @@
# Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. (react/jsx-curly-spacing)

## Rule Details

Since React removes extraneous new lines between elements when possible,
it is possible to end up with inline elements that are not rendered with spaces between them and adjacent text.
This is often indicative of an error, so this rule attempts to detect

The following patterns are considered warnings:

```jsx
<div>
Here is a
<a>link</a>
</div>
```

```jsx
<div>
<b>This text</b>
is bold
</div>
```

The following patterns are **not** considered warnings:

```jsx
<div>
Spacing is
{' '}
<a>explicit</a>
</div>
```

```jsx
<div>
Lack of spacing is{/*
*/}<a>explicit</a>
</div>
```

## When Not To Use It

You can turn this rule off if you are not concerned with inline elements appearing adjacent to text,
or if you always explicitly include `{' '}` between elements to denote spacing.
5 changes: 4 additions & 1 deletion lib/rules/jsx-child-element-spacing.js
@@ -1,5 +1,7 @@
'use strict';

const docsUrl = require('../util/docsUrl');

// This list is taken from https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
const INLINE_ELEMENTS = new Set([
'a',
Expand Down Expand Up @@ -40,7 +42,8 @@ module.exports = {
docs: {
description: 'Ensures inline tags are not rendered without spaces between them',
category: 'Stylistic Issues',
recommended: false
recommended: false,
url: docsUrl('jsx-child-element-spacing')
},
fixable: false,
schema: [
Expand Down