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.

feat(detect): show stacks and platforms in - --list-rules (#59)

Nguyễn Tuấn Anh6bad8029c771
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 2f83e0e..9c4df69 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -999,11 +999,26 @@ function formatText(result) {
}
function listRules() {
+ // A rule with no stacks or platforms restriction applies everywhere;
+ // --list-rules shows that as "all" instead of hiding the field.
+ const show = (v) => (v ? v.join(", ") : "all");
return rules
- .map((r) => `${r.id.padEnd(18)} ${r.severity.padEnd(10)} ${r.family.padEnd(15)} ${r.message}\n${" ".repeat(20)}Fix: ${r.fix}`)
+ .map((r) => `${r.id.padEnd(18)} ${r.severity.padEnd(10)} ${r.family.padEnd(15)} ${r.message}\n${" ".repeat(20)}Fix: ${r.fix}\n${" ".repeat(20)}Stacks: ${show(r.stacks)} | Platforms: ${show(r.platforms)}`)
.join("\n");
}
+function listRulesJson() {
+ return JSON.stringify(rules.map((r) => ({
+ id: r.id,
+ severity: r.severity,
+ family: r.family,
+ message: r.message,
+ fix: r.fix,
+ stacks: r.stacks ? [...r.stacks] : "all",
+ platforms: r.platforms ? [...r.platforms] : "all",
+ })), null, 2);
+}
+
const USAGE = `Usage: unslop-anything detect [paths...] [--json] [--platform mobile|web|universal] [--ignore rule,rule] [--include-tests] [--list-rules]
Scans mobile and web source for generated-looking UI, website-in-a-phone patterns,
@@ -1020,7 +1035,7 @@ function main(argv) {
return 0;
}
if (args.includes("--list-rules")) {
- console.log(listRules());
+ console.log(args.includes("--json") ? listRulesJson() : listRules());
return 0;
}
const json = args.includes("--json");
diff --git a/test/detect.test.js b/test/detect.test.js
index 61b0537..aa98495 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -136,6 +136,38 @@ test("exit codes and json shape", () => {
}
});
+test("--list-rules shows stacks and platforms, and --json includes them", () => {
+ const log = console.log;
+ let out = "";
+ console.log = (s) => (out += s);
+ try {
+ assert.strictEqual(main(["--list-rules"]), 0);
+ assert.strictEqual(out.split("Stacks: ").length - 1, rules.length);
+ assert.ok(out.includes("Stacks: all | Platforms: all")); // slop-gradient: no restriction
+ assert.ok(out.includes("Stacks: all | Platforms: mobile, universal")); // drawer-nav
+ assert.ok(out.includes("Stacks: js, web, css | Platforms: mobile")); // hover-only
+ out = "";
+ assert.strictEqual(main(["--list-rules", "--json"]), 0);
+ const listed = JSON.parse(out);
+ assert.strictEqual(listed.length, rules.length);
+ const byId = new Map(listed.map((r) => [r.id, r]));
+ for (const r of listed) {
+ assert.ok(r.id && r.severity && r.family && r.message && r.fix);
+ assert.ok("stacks" in r && "platforms" in r);
+ }
+ assert.deepStrictEqual(byId.get("slop-gradient").stacks, "all");
+ assert.deepStrictEqual(byId.get("slop-gradient").platforms, "all");
+ assert.deepStrictEqual(byId.get("nested-cards").stacks, ["js", "kotlin", "dart", "web"]);
+ assert.deepStrictEqual(byId.get("nested-cards").platforms, "all");
+ assert.deepStrictEqual(byId.get("drawer-nav").stacks, "all");
+ assert.deepStrictEqual(byId.get("drawer-nav").platforms, ["mobile", "universal"]);
+ assert.deepStrictEqual(byId.get("hover-only").stacks, ["js", "web", "css"]);
+ assert.deepStrictEqual(byId.get("hover-only").platforms, ["mobile"]);
+ } finally {
+ console.log = log;
+ }
+});
+
test("a quote inside a regex literal does not hide a real comment", () => {
assert.deepStrictEqual(scanSource('const quote = /"/g; // Oops\n', "a.ts"), []);
assert.deepStrictEqual(scanSource("<Text>Hi</Text> // Oops\n", "a.tsx"), []);