Skip to content
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

feat: support custom expression precedence #427

Merged

Conversation

devongovett
Copy link
Contributor

A custom generator can be passed to astring to extend it with additional nodes. We are using this in Parcel to convert Babel's AST format to ESTree on-the-fly. However, one limitation is that expression precedence for these node types is unknown to astring. This PR adds support for passing a custom expressionPrecedence map to astring which can extend from the default mapping (which is now exported) in order to support this use case.

@codecov
Copy link

codecov bot commented Jan 4, 2021

Codecov Report

Merging #427 (db7c2fd) into master (6021bf0) will increase coverage by 0.28%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #427      +/-   ##
==========================================
+ Coverage   95.44%   95.72%   +0.28%     
==========================================
  Files           1        1              
  Lines        1119     1123       +4     
==========================================
+ Hits         1068     1075       +7     
+ Misses         51       48       -3     
Impacted Files Coverage Δ
src/astring.js 95.72% <100.00%> (+0.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6021bf0...28c8865. Read the comment docs.

@davidbonnet davidbonnet changed the title Support custom expression precedence feat: support custom expression precedence Jan 4, 2021
@davidbonnet davidbonnet merged commit 76ce709 into davidbonnet:master Jan 4, 2021
@davidbonnet
Copy link
Owner

Thanks @devongovett for suggesting this.
Note that I renamed the option to:

expressionsPrecedence
          ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants