From d466e05edaeb0620462746cf1de8d75959920c6f Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 17 Oct 2024 10:35:14 +0100 Subject: [PATCH] ignore more weirdness --- eslint/locale.js | 2 ++ eslint/locale.test.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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),