Skip to content

Conversation

@garikkh
Copy link
Contributor

@garikkh garikkh commented Oct 16, 2025

Fixes #90

Adds a new rule to prevent t calls inside other functions like plural, Plural and Trans

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 98.18182% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.89%. Comparing base (073664e) to head (ce6c4b9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/rules/no-nested-trans.ts 98.03% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andrii-bodnar
Copy link
Contributor

@garikkh thanks for the contribution, looks nice!

@timofei-iatsenko what do you think?

Copy link
Collaborator

@timofei-iatsenko timofei-iatsenko left a 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.

@garikkh
Copy link
Contributor Author

garikkh commented Nov 5, 2025

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

@garikkh garikkh marked this pull request as draft November 6, 2025 19:32
@garikkh
Copy link
Contributor Author

garikkh commented Nov 10, 2025

@timofei-iatsenko can you point me to a good definition of what is/isn't allowed?

I think there are these functions:

  1. t
  2. plural and Plural
  3. select and Select
  4. selectOrindal and SelectOrdinal
  5. msg and defineMessage
  6. Trans

which combinations are allowed? you can't have t in t or Trans in Trans. And you can't have t in Plural but you can have Trans in Plural - but should that be allowed?

technically Trans in Plural works, but also I don't see any reason to allow it, just looks messy for no reason.

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.

@garikkh garikkh marked this pull request as ready for review November 16, 2025 16:34
@garikkh
Copy link
Contributor Author

garikkh commented Dec 20, 2025

bump @timofei-iatsenko

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.

New Rule: Disallow t inside t

3 participants