Refactor icon validation logic to enforce stricter naming and category rules for outline and filled icons, improving error reporting for invalid configurations.

This commit is contained in:
codecalm 2025-12-23 02:38:33 +01:00
parent 3c47dab3ed
commit a2d526f493
1 changed files with 12 additions and 13 deletions

View File

@ -213,26 +213,25 @@ for (const icon of addedIcons) {
error = true error = true
} }
if (!icon.match(/^[a-z0-9-]+$/)) { if (!icon.match(/^(outline|filled)\/[a-z0-9-]+$/)) {
console.log(`⛔️ New icon \`${icon}\` has invalid name`) console.log(`⛔️ New icon \`${icon}\` has invalid name`)
error = true error = true
} }
// check if outline icon has category // check if outline icon has category
if (icon.match(/^outline\//) && !data.category) { if (icon.match(/^outline\//) ) {
console.log(`⛔️ New icon \`${icon}\` has no category`) if(!data.category) {
error = true console.log(`⛔️ New outline icon \`${icon}\` has no category`)
} else { error = true
if (!categories.includes(data.category)) { } else if (!categories.includes(data.category)) {
console.log(`⛔️ New icon \`${icon}\` has invalid category \`${data.category}\`. Valid categories are: ${categories.join(', ')}`) 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 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 // check if filled icon has tags