You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 🔒 Verifies Lingui macros actually come from `@lingui/*` packages (no false positives from similarly-named functions)
64
65
66
+
## Branded Types for Custom Ignore Patterns
67
+
68
+
For cases not covered by automatic detection (like custom loggers or analytics), this plugin exports branded types you can use to mark strings as "no translation needed":
Copy file name to clipboardExpand all lines: docs/rules/no-unlocalized-strings.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -515,13 +515,33 @@ interface ButtonProps {
515
515
516
516
### How It Works
517
517
518
-
These types use TypeScript's branded type pattern:
518
+
These types use TypeScript's branded type pattern with two different markers:
519
+
520
+
**Parameter-level branding** (`__linguiIgnore`):
519
521
520
522
```ts
521
523
type UnlocalizedLog = string & {readonly__linguiIgnore?:"UnlocalizedLog"}
522
524
```
523
525
524
-
The `__linguiIgnore` property is a phantom type marker—it never exists at runtime. The rule checks for this property in the contextual type to determine if a string should be ignored.
526
+
The rule checks if the parameter's contextual type has this property.
type UnlocalizedFunction<T> = T & {readonly__linguiIgnoreArgs?:true}
532
+
```
533
+
534
+
The rule checks if the object/function being called has this property. If so, all string arguments are ignored.
535
+
536
+
**The `unlocalized()` helper:**
537
+
538
+
```ts
539
+
function unlocalized<T>(value: T): UnlocalizedFunction<T> {
540
+
returnvalueasUnlocalizedFunction<T>
541
+
}
542
+
```
543
+
544
+
This is an identity function—it returns the input unchanged at runtime. But it changes the compile-time type to include the `__linguiIgnoreArgs` brand, enabling automatic type inference without manual annotations.
0 commit comments