From f6cd4c842bcaeddc5bf8b8ec47f6d83fc2f9616e Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 3 Dec 2026 06:37:46 +0800 Subject: [PATCH] refactor(cursor): share plugin string field validation (#16126) --- scripts/lib/cursor-plugin-bundle.mjs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/lib/cursor-plugin-bundle.mjs b/scripts/lib/cursor-plugin-bundle.mjs index 5dd7453172f..3a7ee526c88 100644 --- a/scripts/lib/cursor-plugin-bundle.mjs +++ b/scripts/lib/cursor-plugin-bundle.mjs @@ -72,6 +72,8 @@ const skillFrontmatter = (content) => { return fields; }; +const isNonemptyString = (value) => typeof value === "string" && value !== ""; + /** * Structured differences between the Cursor plugin declaration and the * package version it must launch. Empty means the manifest, server pin, @@ -89,13 +91,10 @@ export const cursorPluginBundleIssues = ({ const add = (field) => issues.push({ field }); if (manifest?.name !== "rea") add("name"); if (manifest?.version !== packageVersion) add("version"); - if (typeof manifest?.description !== "string" || manifest.description === "") - add("description"); - if (typeof manifest?.author?.name !== "string" || manifest.author.name === "") - add("author.name"); + if (!isNonemptyString(manifest?.description)) add("description"); + if (!isNonemptyString(manifest?.author?.name)) add("author.name"); if (manifest?.repository !== CURSOR_PLUGIN_REPOSITORY) add("repository"); - if (typeof manifest?.license !== "string" || manifest.license === "") - add("license"); + if (!isNonemptyString(manifest?.license)) add("license"); if ( !Array.isArray(manifest?.keywords) || manifest.keywords.length === 0 || @@ -120,11 +119,7 @@ export const cursorPluginBundleIssues = ({ ) add("skills.entries"); if (frontmatter?.name !== CURSOR_PLUGIN_SKILL) add("skill.name"); - if ( - typeof frontmatter?.description !== "string" || - frontmatter.description === "" - ) - add("skill.description"); + if (!isNonemptyString(frontmatter?.description)) add("skill.description"); return issues; };