feat: new require-explicit-comment rule#128
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #128 +/- ##
=======================================
Coverage 98.10% 98.10%
=======================================
Files 13 14 +1
Lines 632 685 +53
Branches 212 233 +21
=======================================
+ Hits 620 672 +52
- Misses 12 13 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| attr.name.name === propName, | ||
| ) | ||
|
|
||
| const getObjectProp = (node: TSESTree.ObjectExpression, propName: string) => |
There was a problem hiding this comment.
Both require-explicit-comment and require-explicit-id define nearly identical prop-lookup logic inline. Consider extracting to src/helpers.ts
I have already done this in #131 could potentially be reused.
| missingCommentCall: | ||
| "Macro function call requires an explicit 'comment' property when 'context' is absent", | ||
| noCommentInTaggedTemplate: | ||
| "Tagged template literal doesn't support 'comment'. Use {{ fn }}({ comment: '...', message: '...' }) or provide `context` instead", |
There was a problem hiding this comment.
The tagged template handler always reports, even though the docs say "unless context is provided". Tagged templates genuinely can't carry comment, but they also can't carry context, so the error message suggesting "provide context instead" is misleading. Consider rewording:
"Tagged template literal doesn't support 'comment' or 'context'. Use {{ fn }}({ comment: '...', message: '...' }) instead."
Add
require-explicit-commentrule to enforce translator comments across Lingui macro object calls and React macro components (Trans,Plural,Select,SelectOrdinal), while allowingcontextas an alternative.This aligns with the goal of providing as much contextual information as possible, which results in better translations.