eslint-plugin
eslint-plugin copied to clipboard
`no-unlocalized-strings` should ignore string keys for dereferencing object values
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)