Skip to content
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

no-unlocalized-strings should ignore string keys for dereferencing object values #38

Closed
judeatmerit opened this issue May 2, 2024 · 1 comment · Fixed by #56 or #58
Closed
Labels
bug Something isn't working hacktoberfest help wanted Extra attention is needed

Comments

@judeatmerit
Copy link

judeatmerit commented May 2, 2024

Here's a simple example illustrating what I think should not be flagged by the no-unlocalized-strings rule

const obj = { "key with space": 5 };
const value1 = obj["key with space"]; // disallow literal string, eslint(lingui/no-unlocalized-strings)
const map = new Map(Object.entries(obj));
const value2 = map.get("key with space"); // disallow literal string, eslint(lingui/no-unlocalized-strings)

As shown above, in a case where I need to get a value from an Object using the syntax obj[key] with a literal string, I believe it's a case where the string should never be flagged by the rule. Arguably, the second example with a Map also applies, though at least there's a way to get around this using ignoreFunction.

Somewhat related though arguably separate, I did try using ignoreProperty, but doesn't work for nested keys. I am dealing with an object like the following.

const obj = { ignoredProperty: { "a a": 1, "b b": 2 } };
const value = obj.ignoredProperty["a a"]; // disallow literal string, eslint(lingui/no-unlocalized-strings)
@timofei-iatsenko
Copy link
Collaborator

close in favour of #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest help wanted Extra attention is needed
Projects
None yet
3 participants