Skip to content

Commit b5a948a

Browse files
committed
docs: clarify type-aware detection covers DOM APIs
The existing string literal union detection already covers: - HTMLElementTagNameMap (createElement) - GlobalEventHandlersEventMap (addEventListener) - RequestMode, RequestCredentials, ScrollBehavior, etc.
1 parent a26c988 commit b5a948a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Or configure rules manually:
6868

6969
| Rule | Description | Recommended |
7070
|------|-------------|:-----------:|
71-
| [no-unlocalized-strings](docs/rules/no-unlocalized-strings.md) | Detects user-visible strings not wrapped in Lingui macros. Uses TypeScript types to automatically ignore technical strings like union types and Intl API arguments. ||
71+
| [no-unlocalized-strings](docs/rules/no-unlocalized-strings.md) | Detects user-visible strings not wrapped in Lingui macros. Uses TypeScript types to automatically ignore technical strings like string literal unions, DOM APIs, Intl methods, and discriminated union fields. ||
7272
| [no-single-variable-message](docs/rules/no-single-variable-message.md) | Disallows messages that consist only of a single variable without surrounding text. Such messages provide no context for translators. ||
7373
| [no-single-tag-message](docs/rules/no-single-tag-message.md) | Disallows `<Trans>` components that contain only a single JSX element without text. The wrapped element should be translated directly instead. ||
7474
| [no-nested-macros](docs/rules/no-nested-macros.md) | Prevents nesting Lingui macros inside each other (e.g., `t` inside `<Trans>`). Nested macros create invalid message catalogs and confuse translators. ||

docs/rules/no-unlocalized-strings.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ function setAlign(align: "left" | "center" | "right") {}
7777
setAlign("center") // ✅ Not reported
7878
```
7979

80+
### DOM APIs
81+
82+
```tsx
83+
// All DOM string literal unions are automatically detected
84+
document.createElement("div") // ✅ keyof HTMLElementTagNameMap
85+
element.addEventListener("click", handler) // ✅ keyof GlobalEventHandlersEventMap
86+
fetch(url, { mode: "cors", credentials: "include" }) // ✅ RequestMode, RequestCredentials
87+
element.scrollIntoView({ behavior: "smooth" }) // ✅ ScrollBehavior
88+
```
89+
8090
### Intl-Related Types
8191

8292
```tsx

0 commit comments

Comments
 (0)