-
Notifications
You must be signed in to change notification settings - Fork 17
feat(no-expression-in-message): add support for ph and explicit labels #100
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #100 +/- ##
==========================================
+ Coverage 97.70% 97.75% +0.05%
==========================================
Files 10 10
Lines 479 490 +11
Branches 147 151 +4
==========================================
+ Hits 468 479 +11
Misses 11 11 ☔ View full report in Codecov by Sentry. |
|
Thanks for your contribution. Planned to do in the future together with bigger announcement of this feature. What i also wanted to implement for the eslint rule are:
I shed a bit of light on the future plans. This placeholder implementation is our ticket to make AST macro completely optional. It means all DX and features lingui currently has will be available without transpilation at all. This will come with some syntax limitations, one of them is the inability to infer name of the variable used in expressions. To make transition to the newer approach smoother, I planned to implement an automatic migration (using esling autofix). So, users will make their codebase compatible with a new approach even before this approach would land into the core. Let me know, how you would like to proceed. I will understand if that level of commitment is not what you planned. |
|
Fair points. I thought about different messages, but wanted to push out a fix to allow the upgrade to lingui 5.2 in our team (we really don't like the requirement of intermediate variables for translations 😅). Do you think it's worth pushing this quick fix (even with a tame release notes so people are not excited) or should we wait for a fully fledged functionality? I'm down to contribute this in another PR if you'd like 🙂 |
|
I reviewed your changes carefully one more time, let's at least add another message for this case: {
code: '<Trans>hello {{name: obj.foo, surname: obj.bar}}</Trans>',
errors: [{ messageId: 'default' }],
},Here i would expect an explicit error, something like:
Would be nice if you would read keys from AST, if not, hard-coded value would be enough. After that we can merge it as-is, and then implement an autofix and proposition to use named variable in the next PR. |
|
I tried doing fancy stuff with the message, but Even though eslint allows that: https://github.com/typescript-eslint/typescript-eslint/blob/bcdf56017a1c9d66d701d2104651ae9d9cf035dd/packages/rule-tester/src/utils/interpolate.ts#L30-L31 |
|
@KubaJastrz good job. LGTM. PS Noticed on your github profile that you're learning Rust on your spare time, would you like to test your knowledge on something that will bring a real value and port this feature lingui/js-lingui#2092 into https://github.com/lingui/swc-plugin i can guide you thru the process |
|
@timofei-iatsenko sure, I'll see what I can do |
Support syntax and ph labels introduces in lingui/js-lingui#2092
closes #99