astring
astring copied to clipboard
Add support for JSX
- Add new
JSXexport, similar toGENERATOR, with handlers for JSX nodes - Add unit tests for JSX nodes
- Add JSX example
- I’m a fan of small unit tests over checking whole documents, so I tested the new features with those
- Types are not tested, and I’m not a TS user, so I didn’t add types for
JSX. For reference, if you’re interested, here is an example of how to test types. You could also opt to use JSDoc for typescript if the source is JS, which I quite like, like so. Some complexity with types though is that newer ESTree proposal aren’t typed yet, such as bigint (and I’m not sure where JSX is typed)
Codecov Report
Merging #480 (8b7f1dd) into master (2dfdef1) will increase coverage by
0.77%. The diff coverage is99.26%.
:exclamation: Current head 8b7f1dd differs from pull request most recent head 9f1bbaf. Consider uploading reports for the commit 9f1bbaf to get more accurate results
@@ Coverage Diff @@
## master #480 +/- ##
==========================================
+ Coverage 94.97% 95.74% +0.77%
==========================================
Files 1 1
Lines 1134 1270 +136
==========================================
+ Hits 1077 1216 +139
+ Misses 57 54 -3
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/astring.js | 95.74% <99.26%> (+0.77%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 2dfdef1...9f1bbaf. Read the comment docs.
Thanks @wooorm for sending this, it looks great! Adding inline comments about what a node does is also a great idea. The reason behind template-based tests is to avoid malformed AST nodes and to ensure that sourcemaps match.
I'll have more time next week-end to apply the remaining changes:
- [ ] Add template tests
- [ ] Add TypeScript types
- [ ] Add
generateJsxhelper - [ ] Update demo with JSX support
Edit: not this one but the next one.
here’s a PR somewhere else that types (using JSDoc comments, which I like a lot) these same functions: https://github.com/wooorm/xdm/pull/24, by @ChristianMurphy
Just a quick note to mention that I haven't forgotten this PR.
Let me now if there's anything I could do to unblock it!
Hi guys, I'm looking to do exactly this! Is there any update on when this will be merged, or can I help in any way?
Friendly ping!
@davidbonnet Friendly ping! Anything I can do?