diff --git a/src/rules/no-unlocalized-strings.ts b/src/rules/no-unlocalized-strings.ts index 7a8a2de..53f2249 100644 --- a/src/rules/no-unlocalized-strings.ts +++ b/src/rules/no-unlocalized-strings.ts @@ -368,6 +368,10 @@ export const rule = createRule({ 'Property > Literal'(node: TSESTree.Literal) { onProperty(node) }, + 'MemberExpression[computed=true] > Literal'(node: TSESTree.Literal) { + // obj["key with space"] + visited.add(node) + }, "AssignmentExpression[left.type='MemberExpression'] > Literal"(node: TSESTree.Literal) { const assignmentExp = node.parent as TSESTree.AssignmentExpression const memberExp = assignmentExp.left as TSESTree.MemberExpression @@ -453,6 +457,10 @@ export const rule = createRule({ visited.add(node) } }, + 'MemberExpression[computed=true] > TemplateLiteral'(node: TSESTree.TemplateLiteral) { + // obj[`key with space`] + visited.add(node) + }, 'Property > TemplateLiteral'(node: TSESTree.TemplateLiteral) { onProperty(node) }, diff --git a/tests/src/rules/no-unlocalized-strings.test.ts b/tests/src/rules/no-unlocalized-strings.test.ts index 1ce5099..d10c72b 100644 --- a/tests/src/rules/no-unlocalized-strings.test.ts +++ b/tests/src/rules/no-unlocalized-strings.test.ts @@ -180,6 +180,8 @@ ruleTester.run(name, rule, { code: `const test = { text: 'This is not localized' }`, options: [{ ignoreProperty: ['text'] }], }, + { code: `obj["key with space"] = 5` }, + { code: `obj[\`key with space\`] = 5` }, ], invalid: [