diff --git a/eslint/locale.js b/eslint/locale.js index 7e5f3419fc..f27f160b07 100644 --- a/eslint/locale.js +++ b/eslint/locale.js @@ -12,6 +12,8 @@ function collectMembers(node) { if (!node) return []; if (node.type !== 'MemberExpression') return []; + // this is something like `foo[bar]` + if (node.computed) return []; return [ node.property.name, ...collectMembers(node.parent) ]; } diff --git a/eslint/locale.test.js b/eslint/locale.test.js index 9c7ed0f45d..1c0727b400 100644 --- a/eslint/locale.test.js +++ b/eslint/locale.test.js @@ -23,8 +23,6 @@ ruleTester.run( { valid: [ testCase('i18n.ts.foo.bar'), - // we don't detect the problem here, but should still accept it - testCase('i18n.ts.foo["something"]'), testCase('i18n.ts.top'), testCase('i18n.tsx.foo.baz({x:1})'), testCase('whatever.i18n.ts.blah.blah'), @@ -32,6 +30,9 @@ ruleTester.run( testCase('whatever(i18n.ts.foo.bar)'), testCaseVue(''), testCaseVue(''), + // we don't detect the problem here, but should still accept it + testCase('i18n.ts.foo["something"]'), + testCase('i18n.ts.foo[something]'), ], invalid: [ testCase('i18n.ts.not', 1),