Invalid comment string in jsx, multiline exprassion inside `{}`
MuhammadSawalhy opened this issue · 2 comments
Hey @MuhammadSawalhy, thanks for the bug report!
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 `//` commentstring
jsx_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 😄