You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/jsx-first-prop-new-line.md
+34-7Lines changed: 34 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,12 @@ Ensure correct position of the first property.
7
7
This rule checks whether the first property of all JSX elements is correctly placed. There are three possible configurations:
8
8
*`always`: The first property should always be placed on a new line.
9
9
*`never` : The first property should never be placed on a new line, e.g. should always be on the same line as the Component opening tag.
10
-
*`multiline`: The first property should always be placed on a new line when the properties are spread over multiple lines.
10
+
*`multiline`: The first property should always be placed on a new line when the JSX tag takes up multiple lines.
11
+
*`multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties.
11
12
12
13
The following patterns are considered warnings when configured `"always"`:
13
14
14
-
```js
15
+
```jsx
15
16
<Hello personal={true} />
16
17
17
18
<Hello personal={true}
@@ -21,7 +22,7 @@ The following patterns are considered warnings when configured `"always"`:
21
22
22
23
The following patterns are not considered warnings when configured `"always"`:
23
24
24
-
```js
25
+
```jsx
25
26
<Hello
26
27
personal />
27
28
@@ -32,7 +33,7 @@ The following patterns are not considered warnings when configured `"always"`:
32
33
33
34
The following patterns are considered warnings when configured `"never"`:
34
35
35
-
```js
36
+
```jsx
36
37
<Hello
37
38
personal />
38
39
@@ -43,7 +44,7 @@ The following patterns are considered warnings when configured `"never"`:
43
44
44
45
The following patterns are not considered warnings when configured `"never"`:
45
46
46
-
```js
47
+
```jsx
47
48
<Hello personal={true} />
48
49
49
50
<Hello personal={true}
@@ -53,14 +54,19 @@ The following patterns are not considered warnings when configured `"never"`:
53
54
54
55
The following patterns are considered warnings when configured `"multiline"`:
55
56
56
-
```js
57
+
```jsx
57
58
<Hello personal
58
59
prop />
59
60
```
60
61
62
+
```jsx
63
+
<Hello foo={{
64
+
}} />
65
+
```
66
+
61
67
The following patterns are not considered warnings when configured `"multiline"`:
62
68
63
-
```js
69
+
```jsx
64
70
<Hello personal={true} />
65
71
66
72
<Hello
@@ -69,6 +75,27 @@ The following patterns are not considered warnings when configured `"multiline"`
69
75
/>
70
76
```
71
77
78
+
The following patterns are considered warnings when configured `"multiline-multiprop"`:
79
+
80
+
```jsx
81
+
<Hello foo={{
82
+
}}
83
+
bar />
84
+
```
85
+
86
+
The following patterns are not considered warnings when configured `"multiline-multiprop"`:
87
+
88
+
```jsx
89
+
<Hello foo={{
90
+
}} />
91
+
92
+
<Hello
93
+
foo={{
94
+
}}
95
+
bar
96
+
/>
97
+
```
98
+
72
99
## When not to use
73
100
74
101
If you are not using JSX then you can disable this rule.
0 commit comments