Skip to content

Commit 0a846ac

Browse files
committed
docs: add 'Why TypeScript?' section to README
Highlight the key advantage over traditional i18n linters: - Automatic recognition of technical strings via types - No manual whitelists for DOM APIs, Intl, unions - Zero-config for TypeScript projects
1 parent b5a948a commit 0a846ac

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,35 @@
66

77
ESLint plugin for [Lingui](https://lingui.dev/) with TypeScript type-aware rules.
88

9+
## Why TypeScript?
10+
11+
Traditional i18n linters rely on heuristics and manual whitelists to distinguish user-visible text from technical strings. This leads to false positives and constant configuration tweaking.
12+
13+
This plugin leverages TypeScript's type system to **automatically** recognize technical strings:
14+
15+
```ts
16+
// ✅ Automatically ignored - TypeScript knows these are technical
17+
document.createElement("div") // keyof HTMLElementTagNameMap
18+
element.addEventListener("click", handler) // keyof GlobalEventHandlersEventMap
19+
fetch(url, { mode: "cors" }) // RequestMode
20+
date.toLocaleDateString("de-DE", { weekday: "long" }) // Intl.DateTimeFormatOptions
21+
22+
type Status = "idle" | "loading" | "error"
23+
const status: Status = "loading" // String literal union
24+
25+
// ❌ Reported - actual user-visible text
26+
const message = "Welcome to our app"
27+
<button>Save changes</button>
28+
```
29+
30+
**No configuration needed** for DOM APIs, Intl methods, or your own string literal union types. TypeScript already knows!
31+
932
## Features
1033

1134
- 🔍 Detects incorrect usage of Lingui translation macros
1235
- 📝 Enforces simple, safe expressions inside translated messages
1336
- 🎯 Detects missing localization of user-visible text
14-
- 🧠 Uses TypeScript types to distinguish UI text from technical strings
37+
- 🧠 Zero-config recognition of technical strings via TypeScript types
1538

1639
## Requirements
1740

0 commit comments

Comments
 (0)