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.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
fix: report invalid detector config files (#134)
CloudGPUeb9ac78fb884
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 4390f17..c6a95f0 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -1257,6 +1257,11 @@ const rules = [// ---------- scanning ----------+function unknownRuleIds(ids) {+ const known = new Set(rules.map((r) => r.id));+ return ids.filter((id) => !known.has(id));+}+function loadConfig(root) {// The nearest project config above the scan target wins; the current// directory's config is the last fallback.@@ -1267,12 +1272,25 @@ function loadConfig(root) {}candidates.push(path.join(process.cwd(), ".unslop-anything", "config.json"), path.join(process.cwd(), ".unslopovich", "config.json"));for (const file of candidates) {+ let source;try {- const raw = JSON.parse(fs.readFileSync(file, "utf8"));- return { ignoreRules: raw.ignoreRules || [], ignorePaths: raw.ignorePaths || [] };- } catch {- // No config, or unreadable: use defaults.+ source = fs.readFileSync(file, "utf8");+ } catch (err) {+ if (err.code === "ENOENT") continue;+ throw new Error(`Could not read config ${file}: ${err.message}`);}+ let raw;+ try {+ raw = JSON.parse(source);+ } catch (err) {+ throw new Error(`Could not parse config ${file}: ${err.message}`);+ }+ const ignoreRules = raw.ignoreRules || [];+ const unknown = unknownRuleIds(ignoreRules);+ if (unknown.length) {+ throw new Error(`Config ${file}: Unknown rule: ${unknown.join(", ")}. See --list-rules.`);+ }+ return { ignoreRules, ignorePaths: raw.ignorePaths || [] };}return { ignoreRules: [], ignorePaths: [] };}@@ -1532,8 +1550,7 @@ function main(argv) {return 1;}}- const known = new Set(rules.map((r) => r.id));- const unknown = ignoreRules.filter((r) => !known.has(r));+ const unknown = unknownRuleIds(ignoreRules);if (unknown.length) {console.error(`Unknown rule: ${unknown.join(", ")}. See --list-rules.`);return 1;diff --git a/test/detect.test.js b/test/detect.test.jsindex 22864bb..3509d35 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -595,6 +595,46 @@ test("project config is found above the scan target", () => {}});+function detectWithConfig(config) {+ const fs = require("fs");+ const os = require("os");+ const { spawnSync } = require("child_process");+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "unslop-"));+ const target = path.join(root, "src");+ const file = path.join(target, ".unslop-anything", "config.json");+ try {+ fs.mkdirSync(path.dirname(file), { recursive: true });+ fs.writeFileSync(file, config);+ // A valid ancestor config must not mask errors in the nearer config.+ fs.mkdirSync(path.join(root, ".unslop-anything"));+ fs.writeFileSync(path.join(root, ".unslop-anything", "config.json"), "{}");+ fs.writeFileSync(path.join(target, "styles.css"), ".card { transition: all 0.3s; }\n");+ const run = spawnSync(process.execPath,+ [path.join(__dirname, "..", "bin", "install.js"), "detect", "--json", target],+ { cwd: root, encoding: "utf8" });+ assert.ifError(run.error);+ return { ...run, file };+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+}++test("project config syntax errors stop the detector", () => {+ const run = detectWithConfig('{ "ignoreRules": ["transition-all"], }');+ assert.strictEqual(run.status, 1);+ assert.ok(run.stderr.includes(run.file));+ assert.match(run.stderr, /Could not parse config/);+ assert.strictEqual(run.stdout, "");+});++test("project config rejects unknown rule IDs", () => {+ const run = detectWithConfig('{ "ignoreRules": ["transition-al"] }');+ assert.strictEqual(run.status, 1);+ assert.ok(run.stderr.includes(run.file));+ assert.match(run.stderr, /Unknown rule: transition-al\. See --list-rules\./);+ assert.strictEqual(run.stdout, "");+});+test("a config from before the rename is still read", () => {const fs = require("fs");const os = require("os");