-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Adds no-t-inside-trans-functions rule #111
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #111 +/- ##
==========================================
+ Coverage 97.86% 97.89% +0.02%
==========================================
Files 11 12 +1
Lines 563 618 +55
Branches 187 207 +20
==========================================
+ Hits 551 605 +54
- Misses 12 13 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@garikkh thanks for the contribution, looks nice! @timofei-iatsenko what do you think? |
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.
@garikkh Thanks for the contribution! I have a few change requests:
There are quite a few cases not yet covered — t can appear not only as a TaggedTemplateExpression, but also as a CallExpression in various forms.
Similarly, Trans and Plural are only part of the Lingui API — there are other components that should also be handled.
Covering all possible forms and signatures can be tricky, which is why this plugin provides ready-to-use queries for all Lingui cases in src/helpers.ts.
You can take a look at the src/rules/no-trans-inside-trans.ts rule for reference.
Also, the rule name no-t-inside-trans-function might not fully reflect its purpose, since it’s not limited to Trans. It might be worth considering a more fitting name.
Agreed, originally the only scope was t in trans, but then extended for other cases. I'll check the helper queries, and rename the rule. Might take me a few days to get back to this though |
|
@timofei-iatsenko can you point me to a good definition of what is/isn't allowed? I think there are these functions:
which combinations are allowed? you can't have technically If none are allowed within each other, that is OK too - that's how the latest version of this lint rule checks it as well. |
|
bump @timofei-iatsenko |
Fixes #90
Adds a new rule to prevent
tcalls inside other functions likeplural,PluralandTrans