From 5949e8344eb0f1087c103da1b87361737d4dda85 Mon Sep 17 00:00:00 2001 From: navrkald Date: Mon, 22 Jul 2024 12:32:39 +0200 Subject: [PATCH] Fix of issue id #1674, reporting false positive invalid config warning. --- packages/config/src/load.js | 2 +- packages/core/src/percy.js | 4 ++-- packages/core/src/snapshot.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/config/src/load.js b/packages/config/src/load.js index 730c1d324..34e76bab7 100644 --- a/packages/config/src/load.js +++ b/packages/config/src/load.js @@ -95,7 +95,7 @@ export function load({ config = normalize(config, { overrides, schema: '/config' }); let errors = config && validate(config); - if (errors) { + if (errors?.length > 0) { log.warn('Invalid config:'); for (let e of errors) log.warn(`- ${e.path}: ${e.message}`); if (bail) return; diff --git a/packages/core/src/percy.js b/packages/core/src/percy.js index f1449cf9c..7a350f7ed 100644 --- a/packages/core/src/percy.js +++ b/packages/core/src/percy.js @@ -134,7 +134,7 @@ export class Percy { // validate provided config options let errors = PercyConfig.validate(config); - if (errors) { + if (errors?.length > 0) { this.log.warn('Invalid config:'); for (let e of errors) this.log.warn(`- ${e.path}: ${e.message}`); } @@ -386,7 +386,7 @@ export class Percy { let { clientInfo, environmentInfo, ...comparison } = options; let errors = PercyConfig.validate(comparison, '/comparison'); - if (errors) { + if (errors?.length > 0) { this.log.warn('Invalid upload options:'); for (let e of errors) this.log.warn(`- ${e.path}: ${e.message}`); } diff --git a/packages/core/src/snapshot.js b/packages/core/src/snapshot.js index 7a5b11533..ee192ccbb 100644 --- a/packages/core/src/snapshot.js +++ b/packages/core/src/snapshot.js @@ -196,7 +196,7 @@ export function validateSnapshotOptions(options) { // warn on validation errors let errors = PercyConfig.validate(migrated, schema); - if (errors) { + if (errors?.length > 0) { log.warn('Invalid snapshot options:'); for (let e of errors) log.warn(`- ${e.path}: ${e.message}`); }