Skip to content

Commit 8ef2824

Browse files
committed
docs - jsx-one-expression-per-line
1 parent 3a94a95 commit 8ef2824

File tree

4 files changed

+108
-3
lines changed

4 files changed

+108
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Finally, enable all of the rules that you would like to use. Use [our preset](#
146146
* [react/jsx-no-literals](docs/rules/jsx-no-literals.md): Prevent usage of unwrapped JSX strings
147147
* [react/jsx-no-target-blank](docs/rules/jsx-no-target-blank.md): Prevent usage of unsafe `target='_blank'`
148148
* [react/jsx-no-undef](docs/rules/jsx-no-undef.md): Disallow undeclared variables in JSX
149+
* [react/jsx-one-expression-per-line](docs/rules/jsx-one-expression-per-line.md): Limit to one expression per line in JSX
149150
* [react/jsx-curly-brace-presence](docs/rules/jsx-curly-brace-presence.md): Enforce curly braces or disallow unnecessary curly braces in JSX
150151
* [react/jsx-pascal-case](docs/rules/jsx-pascal-case.md): Enforce PascalCase for user-defined JSX components
151152
* [react/jsx-sort-props](docs/rules/jsx-sort-props.md): Enforce props alphabetical sorting (fixable)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# One JSX Element Per Line (react/jsx-indent)
2+
3+
This option limits every line in JSX to one expression each.
4+
5+
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
6+
Fixer will insert line breaks between any expression that are on the same line.
7+
8+
## Rule Details
9+
10+
The following patterns are considered warnings:
11+
12+
```jsx
13+
<App><Hello /></App>
14+
15+
<App><Hello />
16+
</App>
17+
18+
<App>
19+
<Hello>
20+
</Hello></App>
21+
22+
<App>
23+
</Hello> World
24+
</App>
25+
26+
<App>
27+
</Hello> { 'World' }
28+
</App>
29+
30+
<App>
31+
</Hello> { this.world() }
32+
</App>
33+
34+
<App>
35+
{ 'Hello' }{ ' ' }{ 'World' }
36+
</App>
37+
38+
<App
39+
foo
40+
><Hello />
41+
</App>
42+
43+
<App><Hello
44+
foo
45+
/>
46+
</App>
47+
48+
<App><Hello1 />
49+
<Hello2 />
50+
<Hello3 />
51+
</App>
52+
```
53+
54+
The following patterns are **not** warnings:
55+
56+
```jsx
57+
<App>
58+
<Hello />
59+
</App>
60+
61+
<App>
62+
<Hello>
63+
</Hello>
64+
</App>
65+
66+
<App>
67+
</Hello>
68+
World
69+
</App>
70+
71+
<App>
72+
</Hello>
73+
{ 'World' }
74+
</App>
75+
76+
<App>
77+
</Hello>
78+
{ this.world() }
79+
</App>
80+
81+
<App>
82+
{ 'Hello' }
83+
{ ' ' }
84+
{ 'World' }
85+
</App>
86+
87+
<App
88+
foo
89+
>
90+
<Hello />
91+
</App>
92+
93+
<App>
94+
<Hello
95+
foo
96+
/>
97+
</App>
98+
99+
<App>
100+
<Hello1 />
101+
<Hello2 />
102+
<Hello3 />
103+
</App>
104+
```

lib/rules/jsx-one-expression-per-line.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Limit to one element tag per line in JSX
2+
* @fileoverview Limit to one expression per line in JSX
33
* @author Mark Ivan Allen <Vydia.com>
44
*/
55

@@ -12,7 +12,7 @@
1212
module.exports = {
1313
meta: {
1414
docs: {
15-
description: 'Limit to one element tag per line in JSX',
15+
description: 'Limit to one expression per line in JSX',
1616
category: 'Stylistic Issues',
1717
recommended: false
1818
},

tests/lib/rules/jsx-one-expression-per-line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Limit to one element tag per line in JSX
2+
* @fileoverview Limit to one expression per line in JSX
33
* @author Mark Ivan Allen <Vydia.com>
44
*/
55

0 commit comments

Comments
 (0)