From cfd3959ff8e3b11262b0006dff28d0c957b282a2 Mon Sep 17 00:00:00 2001 From: Patrick Hayes Date: Tue, 30 Jan 2018 12:04:06 -0800 Subject: [PATCH] [Docs] add `jsx-child-element-spacing` --- docs/rules/jsx-child-element-spacing.md | 45 +++++++++++++++++++++++++ lib/rules/jsx-child-element-spacing.js | 5 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 docs/rules/jsx-child-element-spacing.md diff --git a/docs/rules/jsx-child-element-spacing.md b/docs/rules/jsx-child-element-spacing.md new file mode 100644 index 0000000000..f39e87dafa --- /dev/null +++ b/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 +
+ Here is a + link +
+``` + +```jsx +
+ This text + is bold +
+``` + +The following patterns are **not** considered warnings: + +```jsx +
+ Spacing is + {' '} + explicit +
+``` + +```jsx +
+ Lack of spacing is{/* + */}explicit +
+``` + +## 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. diff --git a/lib/rules/jsx-child-element-spacing.js b/lib/rules/jsx-child-element-spacing.js index 82d56917cb..73ea2dc2a7 100644 --- a/lib/rules/jsx-child-element-spacing.js +++ b/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', @@ -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: [