-
Notifications
You must be signed in to change notification settings - Fork 390
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
refactor(macro): remove whitespace cleaning from js macro #1897
refactor(macro): remove whitespace cleaning from js macro #1897
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #1897 +/- ##
==========================================
- Coverage 77.18% 77.16% -0.02%
==========================================
Files 84 84
Lines 2165 2159 -6
Branches 559 557 -2
==========================================
- Hits 1671 1666 -5
Misses 381 381
+ Partials 113 112 -1 ☔ View full report in Codecov by Sentry. |
* feature: robust JSX whitespace handling * cleanup * refactor(js-macro): align whitespacing handling with js version ref: lingui/js-lingui#1897 !BREAKING CHANGE
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.
Tested with RN, seems to work fine. You're on fire @thekip !! ⚡⚡
Description
As other developers noted, whitespace trimming is in JS macro redundant and counterintuitive.
If i write:
I'm expecting to get a message with a line break in the middle, and don't expect this to be trimmed.
Another example:
Note the space after ":", it's expected to be there, but "normalization" will remove it.
Other example would be a markdown, or just a whatever purpose user want to have an original formatting.
This PR completely remove whitespace trimming from JS macro, and left the value as-is.
Second important change
There was an unclear logic around unicode escaping in template literals, which I also removed in favor of always "cooked" value.
The template literal has 2 values, raw and cooked. For some historical reasons, the macro took a "raw" property (i followed git history up to creation of the file to see how this code evolved over time).
Then some additional cleanup happened over the "raw", for example double backslashes were removed to make line breaks works.
Then someone reported (#1098) that unicode sequences doesn't work, and an additional layer of logic was added. Now when there were any unicode sequences the code took "cooked" and "raw" when it's not.
Some of this "fixes" for "raw" string happened in the whitespace normalization process and become broken when I removed it.
I dug into that a little bit more, and found that using "cooked" value always give a correct result.
I'm a little bit concerned about this comment:
Since i didn't find any test covering this. @vonovak may be you can test these changes in React Native?
Types of changes
Fixes #1799
Checklist