-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: no-unlocalized-strings corrected support for interface prop names #95
fix: no-unlocalized-strings corrected support for interface prop names #95
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #95 +/- ##
==========================================
+ Coverage 97.18% 97.45% +0.26%
==========================================
Files 10 10
Lines 427 433 +6
Branches 127 133 +6
==========================================
+ Hits 415 422 +7
+ Misses 12 11 -1 ☔ View full report in Codecov by Sentry. |
Thanks for the contribution. Have a question regarding: interface Props {
message: 'This should be translated'; // ❌ Was not being caught
} How it's going to be translated? What the real use case? In my opinion typescript interfaces should be completely ignored |
Was quite tough to keep matching the previous coverage, but now with some code cleanups and an extended test suite it's green again :) |
That was indeed not right I guess. Valid comment! |
{ | ||
name: 'object literal properties should still be checked', | ||
code: ` | ||
const props = { | ||
label: 'This should be translated' | ||
}; | ||
`, | ||
errors: [{ messageId: 'default' }], | ||
}, | ||
{ | ||
name: 'regular string assignments should still be checked', | ||
code: ` | ||
let message = 'This should be translated'; | ||
`, | ||
errors: [{ messageId: 'default' }], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible the duplication of the cases, we already have these:
{ code: 'const a = `Hello ${nice}`', errors },
{ code: 'export const a = `hello string`;', errors },
{ code: "const ge = 'Select tax code'", errors },
{ code: 'const a = `Foo`;', errors },
{ code: 'var a = {foo: "Bar"};', errors },
{ code: `const test = { text: 'This is not localized' }`, errors },
I know the test suite for this rule is a bit mess, let's not make it even more messier ) Either delete old duplicating cases, or not add a new ones.
Also i tried to somehow group / sort them, so it's easier to spot group of functionality. Like all variants of prop assignments together. All variants of JSX text together, etc.
Thanks!
Done. Reworked the test suite. Improved structure and maintained coverage. Tell me if that's looking better. :) |
I’ve identified three additional issues that I plan to address next week. In the meantime, is there anything else that needs to be adjusted, or can we proceed with merging this? I’d appreciate any feedback or remarks! |
Problem
The
no-unlocalized-strings
ESLint rule was incorrectly flagging string literals used in TypeScript type definitions as untranslated strings:Solution
Modified the rule to properly ignore string literals when they appear in type contexts. All strings in TypeScript type definitions are now correctly ignored as they represent type information rather than actual text content:
Implementation
Testing
Breaking Changes
None. This is a bug fix that improves TypeScript support without affecting the core functionality of the rule.