rjsx-mode
rjsx-mode copied to clipboard
Allow props to take a JSX literal value
Also per the spec on the repo, apparently props can be assigned literal JSX elements directly
JSXAttributeInitializer :
=
JSXAttributeValueJSXAttributeValue :
"
JSXDoubleStringCharactersopt"
'
JSXSingleStringCharactersopt'
{
AssignmentExpression}
- JSXElement
This isn't hard at all, the hardest part is to not mess up indentation even more than it is now. js-mode
's indent-line-function
is just superbly stupid even in Emacs 26.
It'll probably make more sense to reimplement indent-line-function
first.
Oh well, no need to hurry tho, not until Babel 7 is released anyway, whenever that maybe.
It's released! https://babeljs.io/blog/2018/08/27/7.0.0
PRs welcome :) I think it's an easy fix on the parsing side, we just need some tests here. On the indentation side, I'd have to check, but I think there's an assumption that if a node and its parent are both rjsx-node
s, then it's a nested relationship rather than a tag-attribute relationship. If only I'd added an rjsx-tag
node to the parse tree...