From eda444a4ef3dcfed86a51f7bee28160b79ba956b Mon Sep 17 00:00:00 2001 From: "Nicholas Carrigan (he/him)" Date: Sun, 28 Feb 2021 10:35:21 -0800 Subject: [PATCH] tools: disable schema validation (#41300) Changes the schema validation script to print warnings to the console instead of throwing errors. This will no longer cause CI to fail on missing/extra/empty translation object keys. --- client/i18n/schema-validation.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/client/i18n/schema-validation.js b/client/i18n/schema-validation.js index c64a5f4af3..1500942d2d 100644 --- a/client/i18n/schema-validation.js +++ b/client/i18n/schema-validation.js @@ -44,7 +44,7 @@ const findMissingKeys = (file, schema, path) => { } } if (missingKeys.length) { - throw new Error( + console.warn( `${path} is missing these required keys: ${missingKeys.join(', ')}` ); } @@ -65,7 +65,7 @@ const findExtraneousKeys = (file, schema, path) => { } } if (extraKeys.length) { - throw new Error( + console.warn( `${path} has these keys that are not in the schema: ${extraKeys.join( ', ' )}` @@ -132,13 +132,13 @@ const translationSchemaValidation = languages => { ); const emptyKeys = noEmptyObjectValues(fileJson); if (emptyKeys.length) { - throw new Error( + console.warn( `${language}/translation.json has these empty keys: ${emptyKeys.join( ', ' )}` ); } - console.info(`${language} translation.json is correct!`); + console.info(`${language} translation.json validation complete.`); }); }; @@ -160,13 +160,13 @@ const trendingSchemaValidation = languages => { ); const emptyKeys = noEmptyObjectValues(fileJson); if (emptyKeys.length) { - throw new Error( + console.warn( `${language}/trending.json has these empty keys: ${emptyKeys.join( ', ' )}` ); } - console.info(`${language} trending.json is correct!`); + console.info(`${language} trending.json validation complete`); }); }; @@ -190,7 +190,7 @@ const motivationSchemaValidation = languages => { ); const emptyKeys = noEmptyObjectValues(fileJson); if (emptyKeys.length) { - throw new Error( + console.warn( `${language}/motivation.json has these empty keys: ${emptyKeys.join( ', ' )}` @@ -203,11 +203,9 @@ const motivationSchemaValidation = languages => { object.hasOwnProperty('quote') && object.hasOwnProperty('author') ) ) { - throw new Error( - `${language}/motivation.json has malformed quote objects.` - ); + console.warn(`${language}/motivation.json has malformed quote objects.`); } - console.info(`${language} motivation.json is correct!`); + console.info(`${language} motivation.json validation complete`); }); }; @@ -225,11 +223,11 @@ const introSchemaValidation = languages => { findExtraneousKeys(fileKeys, introSchemaKeys, `${language}/intro.json`); const emptyKeys = noEmptyObjectValues(fileJson); if (emptyKeys.length) { - throw new Error( + console.warn( `${language}/intro.json has these empty keys: ${emptyKeys.join(', ')}` ); } - console.info(`${language} intro.json is correct!`); + console.info(`${language} intro.json validation complete`); }); }; @@ -249,13 +247,13 @@ const metaTagsSchemaValidation = languages => { ); const emptyKeys = noEmptyObjectValues(fileJson); if (emptyKeys.length) { - throw new Error( + console.warn( `${language}/metaTags.json has these empty keys: ${emptyKeys.join( ', ' )}` ); } - console.info(`${language} metaTags.json is correct!`); + console.info(`${language} metaTags.json validation complete`); }); };