Skip to content

A library of Agent Skills designed to work with the Stitch MCP server. Each skill follows the Agent Skills open standard, for compatibility with coding agents such as Antigravity, Gemini CLI, Claude Code, Cursor.

TypeScript

fix(validate): don't crash on missing/bad file argument

Emp1500608f346e53bd
diff --git a/plugins/stitch-build/skills/react-components/scripts/validate.js b/plugins/stitch-build/skills/react-components/scripts/validate.js
index 883ba9b..8d1036f 100644
--- a/plugins/stitch-build/skills/react-components/scripts/validate.js
+++ b/plugins/stitch-build/skills/react-components/scripts/validate.js
@@ -21,9 +21,13 @@ import path from 'node:path';
const HEX_COLOR_REGEX = /#[0-9A-Fa-f]{6}/;
async function validateComponent(filePath) {
- const code = fs.readFileSync(filePath, 'utf-8');
- const filename = path.basename(filePath);
+ if (!filePath) {
+ console.error("Usage: node validate.js <path-to-component>");
+ process.exit(1);
+ }
try {
+ const code = fs.readFileSync(filePath, 'utf-8');
+ const filename = path.basename(filePath);
const ast = await swc.parse(code, { syntax: "typescript", tsx: true });
let hasInterface = false;
let tailwindIssues = [];
@@ -70,7 +74,7 @@ async function validateComponent(filePath) {
process.exit(1);
}
} catch (err) {
- console.error("❌ PARSE ERROR:", err.message);
+ console.error("❌ ERROR:", err.message);
process.exit(1);
}
}
diff --git a/plugins/stitch-build/skills/react-native/scripts/validate.js b/plugins/stitch-build/skills/react-native/scripts/validate.js
index e91a461..56c9e30 100644
--- a/plugins/stitch-build/skills/react-native/scripts/validate.js
+++ b/plugins/stitch-build/skills/react-native/scripts/validate.js
@@ -23,9 +23,13 @@ const RGBA_COLOR_REGEX = /^rgba?\(\s*\d/;
const HTML_ELEMENTS = ['div', 'span', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'button', 'a', 'input', 'ul', 'ol', 'li', 'section', 'header', 'footer', 'nav', 'main'];
async function validateComponent(filePath) {
- const code = fs.readFileSync(filePath, 'utf-8');
- const filename = path.basename(filePath);
+ if (!filePath) {
+ console.error("Usage: node validate.js <path-to-component>");
+ process.exit(1);
+ }
try {
+ const code = fs.readFileSync(filePath, 'utf-8');
+ const filename = path.basename(filePath);
const ast = await swc.parse(code, { syntax: "typescript", tsx: true });
let hasInterface = false;
let hasExportedInterface = false;
@@ -112,7 +116,7 @@ async function validateComponent(filePath) {
process.exit(1);
}
} catch (err) {
- console.error("PARSE ERROR:", err.message);
+ console.error("ERROR:", err.message);
process.exit(1);
}
}