-
-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: feat: adds frag
snippet
#738
base: master
Are you sure you want to change the base?
Conversation
This PR requires additional improvements:
|
21957c0
to
f8cb14c
Compare
@sergeche Hey! I didn't see a CONTRIBUTING.md guide (I could help create one if needed) so I created this branch and marked it as WIP to show that some work is in progress. Its defineitely not ready yet. Thanks for the comments! I'll expand the test coverage to cover all possible cases for sure. I'm still in the process of understanding what's going on here in general. For now, I've created a separate I've already added the support for Quick question: since |
@@ -82,6 +82,14 @@ function element(node: AbbreviationNode, index: number, items: AbbreviationNode[ | |||
pushString(out, `</${name}>`); | |||
commentNodeAfter(node, state); | |||
} | |||
} else if (config.options['jsx.enabled'] && !node.name) { | |||
// Handle JSX fragment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That defineitely should be tweaked, but Im not sure yet if its a valid way to handle jsx fragment in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, nodes without name could be a (group)
, e.g. (ul>.item*4)+footer
const config: UserConfig = { options: { "jsx.enabled": true } }; | ||
|
||
it("should expand fragment", () => { | ||
// should it work without explicit jsx.enabled ? It's not a valid html tag afaik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the question i had. Should the result actually be expanded to <></>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s OK to expand to <>\n\t${0}\n</>
since its use case is to insert multiple nodes which will be formatted anyways
// should it work without explicit jsx.enabled ? It's not a valid html tag afaik | ||
equal(expand("frag"), "<></>"); | ||
// invalid result, adds one more fragment | ||
equal(expand("frag", config), "<></>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: actual result is invalid (<><></></>
)
// invalid result, adds one more fragment at start | ||
equal( | ||
expand("frag>ul>li*4", config), | ||
"<><ul>\n\t<li></li>\n\t<li></li>\n\t<li></li>\n\t<li></li>\n</ul></>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: actual result is invalid (<><></><ul>\n\t<li></li>\n\t<li></li>\n\t<li></li>\n\t<li></li>\n</ul></>
)
fixes #735
🚧 This PR is not ready yet
Resolves to React.Fragment shorthand <></>