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/no-inline-comments.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,3 +35,55 @@ var foo = 5;
35
35
var bar =5;
36
36
//This is a comment below a line of code
37
37
```
38
+
39
+
### JSX exception
40
+
41
+
Comments inside the curly braces in JSX are allowed to be on the same line as the braces, but only if they are not on the same line with other code, and the braces do not enclose an actual expression.
42
+
43
+
Examples of **incorrect** code for this rule:
44
+
45
+
```js
46
+
/*eslint no-inline-comments: "error"*/
47
+
48
+
var foo =<div>{ /* On the same line with other code */ }<h1>Some heading</h1></div>;
49
+
50
+
var bar = (
51
+
<div>
52
+
{ // These braces are not just for the comment, so it can't be on the same line
53
+
baz
54
+
}
55
+
</div>
56
+
);
57
+
```
58
+
59
+
Examples of **correct** code for this rule:
60
+
61
+
```js
62
+
/*eslint no-inline-comments: "error"*/
63
+
64
+
var foo = (
65
+
<div>
66
+
{/* These braces are just for this comment and there is nothing else on this line */}
0 commit comments