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
In JSX, a multi-line call expression should have the normal js
`commentstring`. For example:
```jsx
<div>
{hello({
foo: 'bar',
})}
</div>
```
Commenting the line with `foo: 'bar',` shouldn't use the JSX comment
style.
There are other similar cases that might fail though, for example, a
multi-line array or string, but those are even rarer cases.
Related to #22
I added an extra rule for this exact use-case, but in general, it's a bit tricky to detect similar multi-line expressions inside {} with the current logic. I think that it would require thinking through the problem a bit more.
Together with the {}, the treesitter node is called jsx_expression but we can't really configure jsx_expression: '// %s', because then commenting a single-line expression would be incorrect. The first idea I had was that we could detect if the parent of a node is jsx_expression. We could have a hypothetical configuration like so:
javascript= {
__default='// %s',
jsx_element='{/* %s */}',
jsx_fragment='{/* %s */}',
jsx_attribute='// %s',
comment='// %s',
__parent= {
-- if a node has this as the parent, use the `//` commentstringjsx_expression='// %s',
},
}
Anyways, I'm not sure if I'll have time to implement this soon. Hopefully the current fix is good enough for now 😄
Here is the current
commentsting
:Here is what I expected:
The text was updated successfully, but these errors were encountered: