diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-10-16 15:56:48 +0100 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-10-22 12:02:24 +0100 |
| commit | f11536c927e0ce4fdc18e3c179835cdde3942b5a (patch) | |
| tree | 6e045c2f011018994893afe72db267854f0651f4 | |
| parent | fix argument/parameter checking (diff) | |
| download | sharkey-f11536c927e0ce4fdc18e3c179835cdde3942b5a.tar.gz sharkey-f11536c927e0ce4fdc18e3c179835cdde3942b5a.tar.bz2 sharkey-f11536c927e0ce4fdc18e3c179835cdde3942b5a.zip | |
ignore weirder cases
| -rw-r--r-- | eslint/locale.js | 7 | ||||
| -rw-r--r-- | eslint/locale.test.js | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/eslint/locale.js b/eslint/locale.js index 60ae21e6e5..a686a4b616 100644 --- a/eslint/locale.js +++ b/eslint/locale.js @@ -23,7 +23,7 @@ function collectMembers(node) { */ function walkDown(locale, path) { if (!locale) return null; - if (!path || path.length === 0) return locale; + if (!path || path.length === 0 || !path[0]) return locale; return walkDown(locale[path[0]], path.slice(1)); } @@ -112,6 +112,11 @@ function theRule(context) { return; } + // we hit something weird, assume the programmers know what + // they're doing (this is usually some complicated slicing of + // the translation structure) + if (typeof(translation) !== 'string') return; + // some more checks on how the translation is called if (method == 'ts') { if (translation.match(/\{/)) { diff --git a/eslint/locale.test.js b/eslint/locale.test.js index f08950b8c7..626fe1587c 100644 --- a/eslint/locale.test.js +++ b/eslint/locale.test.js @@ -11,6 +11,8 @@ ruleTester.run( { valid: [ {code: 'i18n.ts.foo.bar', options: [locale] }, + // we don't detect the problem here, but should still accept it + {code: 'i18n.ts.foo["something"]', options: [locale] }, {code: 'i18n.ts.top', options: [locale] }, {code: 'i18n.tsx.foo.baz({x:1})', options: [locale] }, {code: 'whatever.i18n.ts.blah.blah', options: [locale] }, |