From d94c7d12324e5fb615c8d3a7aed7f938fc7f464e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 9 Aug 2021 19:32:44 +0200 Subject: [PATCH] build: harden locale pack check for unused or duplicate key (#3081) --- bin/locale-packs.js | 2 ++ packages/@uppy/dashboard/src/components/AddFiles.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/bin/locale-packs.js b/bin/locale-packs.js index e8d115b9b..ff58b27c7 100644 --- a/bin/locale-packs.js +++ b/bin/locale-packs.js @@ -128,6 +128,7 @@ function addLocaleToPack (localePack, plugin, pluginName) { console.error(` Value in plugin: ${chalk.cyan(valueInPlugin)}`) console.error(` Value in pack : ${chalk.yellow(valueInPack)}`) console.error() + throw new Error(`Duplicate locale key: '${key}'`) } localePack[key] = localeStrings[key] // eslint-disable-line no-param-reassign } @@ -139,6 +140,7 @@ function checkForUnused (fileContents, pluginName, localePack) { const regPat = new RegExp(`(i18n|i18nArray)\\([^\\)]*['\`"]${key}['\`"]`, 'g') if (!buff.match(regPat)) { console.error(`⚠ defaultLocale key: ${chalk.magenta(key)} not used in plugin: ${chalk.cyan(pluginName)}`) + throw new Error(`Unused locale key: '${key}'`) } } } diff --git a/packages/@uppy/dashboard/src/components/AddFiles.js b/packages/@uppy/dashboard/src/components/AddFiles.js index af7e4ac12..47907f792 100644 --- a/packages/@uppy/dashboard/src/components/AddFiles.js +++ b/packages/@uppy/dashboard/src/components/AddFiles.js @@ -174,6 +174,16 @@ class AddFiles extends Component { ) } + [Symbol.for('uppy test: disable unused locale key warning')] () { + // Those are actually used in `renderDropPasteBrowseTagline` method. + this.props.i18nArray('dropPasteBoth') + this.props.i18nArray('dropPasteFiles') + this.props.i18nArray('dropPasteFolders') + this.props.i18nArray('dropPasteImportBoth') + this.props.i18nArray('dropPasteImportFiles') + this.props.i18nArray('dropPasteImportFolders') + } + renderAcquirer = (acquirer) => { return (