File tree 2 files changed +49
-1
lines changed
2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. (react/jsx-curly-spacing)
2
+
3
+ ## Rule Details
4
+
5
+ Since React removes extraneous new lines between elements when possible,
6
+ it is possible to end up with inline elements that are not rendered with spaces between them and adjacent text.
7
+ This is often indicative of an error, so this rule attempts to detect
8
+
9
+ The following patterns are considered warnings:
10
+
11
+ ``` jsx
12
+ < div>
13
+ Here is a
14
+ < a> link< / a>
15
+ < / div>
16
+ ```
17
+
18
+ ``` jsx
19
+ < div>
20
+ < b> This text< / b>
21
+ is bold
22
+ < / div>
23
+ ```
24
+
25
+ The following patterns are ** not** considered warnings:
26
+
27
+ ``` jsx
28
+ < div>
29
+ Spacing is
30
+ {' ' }
31
+ < a> explicit< / a>
32
+ < / div>
33
+ ```
34
+
35
+ ``` jsx
36
+ < div>
37
+ Lack of spacing is{/*
38
+ */ }< a> explicit< / a>
39
+ < / div>
40
+ ```
41
+
42
+ ## When Not To Use It
43
+
44
+ You can turn this rule off if you are not concerned with inline elements appearing adjacent to text,
45
+ or if you always explicitly include ` {' '} ` between elements to denote spacing.
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ const docsUrl = require ( '../util/docsUrl' ) ;
4
+
3
5
// This list is taken from https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
4
6
const INLINE_ELEMENTS = new Set ( [
5
7
'a' ,
@@ -40,7 +42,8 @@ module.exports = {
40
42
docs : {
41
43
description : 'Ensures inline tags are not rendered without spaces between them' ,
42
44
category : 'Stylistic Issues' ,
43
- recommended : false
45
+ recommended : false ,
46
+ url : docsUrl ( 'jsx-child-element-spacing' )
44
47
} ,
45
48
fixable : false ,
46
49
schema : [
You can’t perform that action at this time.
0 commit comments