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(detect): skip fixed-text-size in Swift files that build for macOS only (#171)
Onur Ugur13cfb494533b
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 952c25a..54bc83d 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -625,6 +625,26 @@ function gradientScope(text, start, name) {// ---------- rules ----------// Each rule gets ctx { code, stack, file } and returns indexes into code.+// A Swift file that imports AppKit or Cocoa outside any #if, and never imports+// UIKit, builds for macOS only: AppKit does not exist on iOS. macOS does not+// support Dynamic Type for third-party apps, so a fixed size there is not a+// tell. An import inside #if os(macOS) says nothing, since the rest of the+// file may build for iOS.+function macOnlySwift(code) {+ const imports = /^[ \t]*(?:@\w+[ \t]+)*(?:(?:public|package|internal|fileprivate|private)[ \t]+)?import[ \t]+(?:(?:class|struct|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/;+ let depth = 0;+ let appKit = false;+ for (const line of code.split("\n")) {+ if (/^[ \t]*#if\b/.test(line)) depth++;+ else if (/^[ \t]*#endif\b/.test(line)) depth = Math.max(0, depth - 1);+ const m = imports.exec(line);+ if (!m) continue;+ if (m[1] === "UIKit") return false;+ if (depth === 0 && (m[1] === "AppKit" || m[1] === "Cocoa")) appKit = true;+ }+ return appKit;+}+function glowLayers(list) {const layers = [];let depth = 0;@@ -943,6 +963,7 @@ const rules = [fix: "Use platform text styles (.body, MaterialTheme.typography, textTheme) or scale custom sizes (relativeTo:, UIFontMetrics, sp). Then check the screen at the largest size.",find({ code, stack }) {if (stack === "swift") {+ if (macOnlySwift(code)) return [];const hits = [...matches(/\.system\(\s*size:|\.custom\(\s*"[^"]*"\s*,\s*size:\s*[\d.]+\s*\)/, code)].map((m) => m.index);if (!/UIFontMetrics|adjustsFontForContentSizeCategory/.test(code)) {for (const m of matches(/UIFont\.(?:systemFont|boldSystemFont)\(\s*ofSize:|UIFont\(\s*name:/, code)) hits.push(m.index);diff --git a/test/detect.test.js b/test/detect.test.jsindex 13983a5..1eae026 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -90,6 +90,36 @@ test("safe-area-off flags .ignoresSafeArea(.all) forms, not backgrounds", () =>assert.deepStrictEqual(scanSource("VStack { }.ignoresSafeArea(edges: .top)", "a.swift"), []);});+test("fixed-text-size skips Swift files that build for macOS only", () => {+ const rulesOf = (src) => scanSource(src, "a.swift").filter((f) => f.rule === "fixed-text-size").map((f) => f.line);+ const text = 'Text("Hi").font(.system(size: 13))\n';+ // AppKit or Cocoa at the top level: the file cannot build for iOS.+ assert.deepStrictEqual(rulesOf("import SwiftUI\nimport AppKit\n" + text), []);+ assert.deepStrictEqual(rulesOf("import Cocoa\n" + text), []);+ assert.deepStrictEqual(rulesOf("@preconcurrency import AppKit\n" + text), []);+ assert.deepStrictEqual(rulesOf("import class AppKit.NSWorkspace\n" + text), []);+ assert.deepStrictEqual(rulesOf("import AppKit.NSView\n" + text), []);+ assert.deepStrictEqual(rulesOf("internal import AppKit\n" + text), []);+ assert.deepStrictEqual(rulesOf("#if DEBUG\n#if os(macOS)\nlet x = 1\n#endif\n#endif\nimport AppKit\n" + text), []);+ assert.deepStrictEqual(rulesOf("import AppKit\nlet f = NSFont.systemFont(ofSize: 13)\n" + text), []);+ // No AppKit, or AppKit only inside #if: the file may build for iOS.+ assert.deepStrictEqual(rulesOf("import SwiftUI\n" + text), [2]);+ assert.deepStrictEqual(rulesOf("import SwiftUI\n#if os(macOS)\nimport AppKit\n#endif\n" + text), [5]);+ assert.deepStrictEqual(rulesOf("#if canImport(AppKit)\nimport AppKit\n#else\nimport UIKit\n#endif\n" + text), [6]);+ assert.deepStrictEqual(rulesOf("import SwiftUI\n#if os(iOS)\nlet x = 1\n#elseif os(macOS)\nimport AppKit\n#endif\n" + text), [7]);+ assert.deepStrictEqual(rulesOf("#if DEBUG\n#if os(macOS)\n#endif\nimport AppKit\n#endif\n" + text), [6]);+ // UIKit anywhere: the file may build for iOS.+ assert.deepStrictEqual(rulesOf("import AppKit\nimport UIKit\n" + text), [3]);+ assert.deepStrictEqual(rulesOf("import AppKit\npublic import UIKit\n" + text), [3]);+ // A commented-out import does not count.+ assert.deepStrictEqual(rulesOf("// import AppKit\n" + text), [2]);+ // Other rules still run on macOS files.+ const other = 'Text("🚀 Launch")\nScrollView { VStack { ForEach(items) { Row($0) } } }\n';+ const expected = scanSource(other, "a.swift").map((f) => f.rule);+ assert.ok(expected.length > 0);+ assert.deepStrictEqual(scanSource("import AppKit\n" + other, "a.swift").map((f) => f.rule), expected);+});+test("commented-out code is ignored", () => {const src = '// <LinearGradient colors={["#7C3AED", "#EC4899"]} />\n/* Oops! Something went wrong */\n';assert.deepStrictEqual(scanSource(src, "a.tsx"), []);