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

Added jsescOptions to Numeric Literals #11028

Merged
merged 9 commits into from Mar 16, 2020

Conversation

sidntrivedi012
Copy link
Contributor

@sidntrivedi012 sidntrivedi012 commented Jan 17, 2020

Q                       A
Fixed Issues? Fixes #10960
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link babel/website#2172
Any Dependency Changes?
License MIT

@sidntrivedi012
Copy link
Contributor Author

Reffered the code from StringLiteral function for Numeric Literals. What can we use here instead of this.format.jsonCompatibleStrings for Numeric Literals?

@JLHwung JLHwung added pkg: generator PR: New Feature 🚀 A type of pull request used for our changelog categories labels Jan 17, 2020
@sidntrivedi012
Copy link
Contributor Author

@JLHwung Made the changes. But it is affecting other tests. PTAL.

@sidntrivedi012
Copy link
Contributor Author

sidntrivedi012 commented Jan 20, 2020

@JLHwung @nicolo-ribaudo PTAL now.

  • Have added conditions in types.js to check where jsesc will need to be applied.
  • Have also added a test.
  • Alongwith this, have made separate optional.json files for jsonEscape and NumericLiteral folders respectively in fixtures.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the logic should be something like this:

  1. Is this.format.jsescOption.numbers is set,
    i. Call this.number(jsesc(node.value, this.format.jsescOption))
  2. Otherwise, fallback to our old unmodified logic.

If someone sets this.format.jsescOption.numbers, they are explicitly overwriting any other automatic logic used to format numbers (i.e. literal length when minified: true, or "use the raw value if it's possible").

@sidntrivedi012
Copy link
Contributor Author

@nicolo-ribaudo @JLHwung PTAL now. Have modified the conditions as mentioned above.

@sidntrivedi012
Copy link
Contributor Author

@nicolo-ribaudo Made the changes. PTAL now.

@sidntrivedi012
Copy link
Contributor Author

@nicolo-ribaudo Done. Please review.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicolo-ribaudo nicolo-ribaudo added this to the v7.9.0 milestone Jan 21, 2020
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 16, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[babel-generator]: jsescOption.numbers does not affect NumericLiterals
3 participants