From a2d526f49354ac893b4233ef83c1b3c7c6488098 Mon Sep 17 00:00:00 2001 From: codecalm Date: Tue, 23 Dec 2025 02:38:33 +0100 Subject: [PATCH] Refactor icon validation logic to enforce stricter naming and category rules for outline and filled icons, improving error reporting for invalid configurations. --- .build/validate-icons.mjs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.build/validate-icons.mjs b/.build/validate-icons.mjs index c557f8513..f5cb0d057 100644 --- a/.build/validate-icons.mjs +++ b/.build/validate-icons.mjs @@ -213,26 +213,25 @@ for (const icon of addedIcons) { error = true } - if (!icon.match(/^[a-z0-9-]+$/)) { + if (!icon.match(/^(outline|filled)\/[a-z0-9-]+$/)) { console.log(`⛔️ New icon \`${icon}\` has invalid name`) error = true } // check if outline icon has category - if (icon.match(/^outline\//) && !data.category) { - console.log(`⛔️ New icon \`${icon}\` has no category`) - error = true - } else { - if (!categories.includes(data.category)) { - console.log(`⛔️ New icon \`${icon}\` has invalid category \`${data.category}\`. Valid categories are: ${categories.join(', ')}`) + if (icon.match(/^outline\//) ) { + if(!data.category) { + console.log(`⛔️ New outline icon \`${icon}\` has no category`) + error = true + } else if (!categories.includes(data.category)) { + console.log(`⛔️ New outline icon \`${icon}\` has invalid category \`${data.category}\`. Valid categories are: ${categories.join(', ')}`) + error = true + } + } else { + if (icon.match(/^filled\//) && data.category) { + console.log(`⛔️ New filled icon \`${icon}\` has category, but should not have it`) error = true } - } - - // check if filled icon hasnt category - if (icon.match(/^filled\//) && data.category) { - console.log(`⛔️ New icon \`${icon}\` has category, but should not have it`) - error = true } // check if filled icon has tags