Skip to content

Commit ceae7a1

Browse files
committed
feat(no-unlocalized-strings): skip strings without any letters
- Numeric/symbolic strings like "1,00€", "100%", "12:30" are technical - Uses Unicode \p{L} to detect letters (supports umlauts, accents, etc.)
1 parent 8a88bf8 commit ceae7a1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/rules/no-unlocalized-strings.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@ ruleTester.run("no-unlocalized-strings", noUnlocalizedStrings, {
127127
{ code: 'const sep = "-"', filename: "test.tsx" },
128128
{ code: 'const x = "."', filename: "test.tsx" },
129129

130+
// Numeric/symbolic strings (no letters at all)
131+
{ code: 'const x = "1000"', filename: "test.tsx" },
132+
{ code: 'const x = "1.000"', filename: "test.tsx" },
133+
{ code: 'const x = "1,00"', filename: "test.tsx" },
134+
{ code: 'const x = "1,00€"', filename: "test.tsx" },
135+
{ code: 'const x = "€100"', filename: "test.tsx" },
136+
{ code: 'const x = "1,00 2,00 3,00"', filename: "test.tsx" },
137+
{ code: 'const x = "100%"', filename: "test.tsx" },
138+
{ code: 'const x = "$99.99"', filename: "test.tsx" },
139+
{ code: 'const x = "12:30"', filename: "test.tsx" },
140+
{ code: 'const x = "2024-01-15"', filename: "test.tsx" },
141+
{ code: 'const x = "→ ← ↑ ↓"', filename: "test.tsx" },
142+
130143
// Empty strings
131144
{ code: 'const x = ""', filename: "test.tsx" },
132145
{ code: 'const x = " "', filename: "test.tsx" },

src/rules/no-unlocalized-strings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ function looksLikeUIString(value: string): boolean {
288288
return true
289289
}
290290

291+
// No letters at all - likely numeric/symbolic (e.g., "1,00€", "1.000", "100%")
292+
if (!/\p{L}/u.test(trimmed)) {
293+
return false
294+
}
295+
291296
// Contains letters AND spaces - likely a phrase or sentence
292297
if (/[a-zA-Z]/.test(trimmed) && /\s/.test(trimmed)) {
293298
return true

0 commit comments

Comments
 (0)