Skip to content

Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.

fix(cli): print concise error when --ignore is missing a value (#119)

Papito084f50316d76f90
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 7155946..0dc5f14 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1465,11 +1465,15 @@ function main(argv) {
return 1;
}
} else if (a === "--ignore") {
- if (!args[i + 1]) {
- console.error(USAGE);
+ const value = args[i + 1];
+ if (!value || value.startsWith("--")) {
+ console.error(
+ "Missing value for --ignore. Pass rule ids separated by commas; see --list-rules."
+ );
return 1;
}
- ignoreRules.push(...args[++i].split(","));
+ i++;
+ ignoreRules.push(...value.split(","));
} else if (!a.startsWith("--")) targets.push(a);
else if (!["--json", "--include-tests"].includes(a)) {
console.error(`Unknown option ${a}\n\n${USAGE}`);
diff --git a/test/detect.test.js b/test/detect.test.js
index 269d268..be9768c 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -226,6 +226,29 @@ test("--fail-on chooses which severity fails the scan", () => {
}
});
+test("--ignore errors cleanly when value is missing or followed by another flag", () => {
+ const err = console.error;
+ let errOut = "";
+ console.error = (m) => {
+ errOut += m;
+ };
+ try {
+ assert.strictEqual(main([path.join(fixtures, "slop"), "--ignore"]), 1);
+ assert.strictEqual(
+ errOut,
+ "Missing value for --ignore. Pass rule ids separated by commas; see --list-rules."
+ );
+ errOut = "";
+ assert.strictEqual(main([path.join(fixtures, "slop"), "--ignore", "--json"]), 1);
+ assert.strictEqual(
+ errOut,
+ "Missing value for --ignore. Pass rule ids separated by commas; see --list-rules."
+ );
+ } finally {
+ console.error = err;
+ }
+});
+
test("--list-rules shows stacks and platforms, and --json includes them", () => {
const log = console.log;
let out = "";