-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cleanup(js): factor code-frames in nx #14585
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Left one comment regarding the highlight function, but it's not a show stopper.
Are there any concerns for terminals that don't display colors? Maybe some CI systems? For local development this makes sense, just want to check if we thought about fallbacks. Thanks for the PR! |
@meeroslav great suggestion. I'll update the PR soonish. @jaysoo my understanding is that chalk handles that. Also this PR does not add colors but only re-use the existing JS error display for JSON. Thanks to both of you for the feedback |
I have rebased/updated the PR. Should be ready to go in if the CI is green. |
Thanks. Let's merge it. |
Thanks! |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
I recently sent a PR to display nicely formatted JSON errors (#14293) and then realize that there was something similar for JS in the
js
package - code-frames.This PR factor the code-frames code in
nx
so that it is used in both cases (formatting JSON and JS errors).This PR also clean up unused code in
packages/js/src/utils/code-frames/identifiers.ts
. It is very unlikely that someone else use the removed code. To make sure I run a query on github an the only usages were from inside nx.The only difference between formatting a JS error vs a JSON error is that
codeFrameColumns
use to highlight the JS code passed to it. I have changed that so that the highlighted code is now passed in the options. That is used for JS but not for JSON - we don't highlight JSON code.The colored test snapshots are not very readable but I made sure all of them are correct in
bash
: