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): catch vague buttons in Swift, Kotlin and Dart (#56)
Nguyễn Tuấn Anh33912400c1df
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex e2a43af..483d2d6 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -804,7 +804,22 @@ const rules = [message: "Button label that does not say what happens.",fix: "Use a verb and an object: \"Save address\", \"Send invoice\", \"Book table\".",find({ code }) {- return [...matches(/(?:title|label|text)\s*[=:]\s*\{?\s*["'](?:Submit|Click here|Tap here)["']|>\s*(?:Submit|Click here|Tap here)\s*</i, code)].map((m) => m.index);+ const hits = [...matches(/(?:title|label|text)\s*[=:]\s*\{?\s*["'](?:Submit|Click here|Tap here)["']|>\s*(?:Submit|Click here|Tap here)\s*</i, code)].map((m) => m.index);+ // Native buttons: the label only counts inside a button call, so a+ // bare Text("Submit") used as a heading or field label stays quiet.+ // Button("Submit") { save() } (Swift), Button(onClick = {}) {+ // Text("Submit") } (Compose trailing lambda), ElevatedButton(...,+ // child: Text("Submit")) (Flutter). Only the first argument or a+ // Text(...) label counts, so a vague string in the action code does not.+ const label = /^\(\s*["'](?:Submit|Click here|Tap here)["']|\bText\(\s*["'](?:Submit|Click here|Tap here)["']/i;+ for (const m of matches(/\b(?:ElevatedButton|TextButton|OutlinedButton|FilledButton|Button)\s*\(/, code)) {+ const open = m.index + m[0].length - 1;+ let end = closeOf(code, open);+ const lambda = /^\s*\{/.exec(code.slice(end));+ if (lambda) end = closeOf(code, end + lambda[0].length - 1);+ if (label.test(code.slice(open, end))) hits.push(m.index);+ }+ return hits;},},{diff --git a/test/detect.test.js b/test/detect.test.jsindex ccb3c23..563e7c1 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -26,21 +26,21 @@ test("React Native slop is caught", () => {test("SwiftUI slop is caught", () => {const found = rulesIn("Dashboard.swift");- for (const id of ["unvirtualized-list", "status-dot", "fixed-text-size", "slop-gradient", "glow-shadow", "back-gesture", "drawer-nav", "safe-area-off", "tracked-caps-label"]) {+ for (const id of ["unvirtualized-list", "status-dot", "fixed-text-size", "slop-gradient", "glow-shadow", "back-gesture", "drawer-nav", "safe-area-off", "tracked-caps-label", "vague-button"]) {assert.ok(found.has(id), `missing ${id}`);}});test("Compose slop is caught", () => {const found = rulesIn("MainScreen.kt");- for (const id of ["template-theme", "unvirtualized-list", "nested-cards", "status-dot", "drawer-nav", "back-gesture"]) {+ for (const id of ["template-theme", "unvirtualized-list", "nested-cards", "status-dot", "drawer-nav", "back-gesture", "vague-button"]) {assert.ok(found.has(id), `missing ${id}`);}});test("Flutter slop is caught", () => {const found = rulesIn("home.dart");- for (const id of ["template-theme", "back-gesture", "unvirtualized-list", "nested-cards", "status-dot", "fixed-text-size"]) {+ for (const id of ["template-theme", "back-gesture", "unvirtualized-list", "nested-cards", "status-dot", "fixed-text-size", "vague-button"]) {assert.ok(found.has(id), `missing ${id}`);}});@@ -215,6 +215,23 @@ test("transition-all flags `all` anywhere in a transition list", () => {assert.deepStrictEqual(scanSource(named, "a.css"), []);});+test("vague-button catches Swift, Compose and Flutter buttons", () => {+ assert.deepStrictEqual(scanSource('Button("Submit") { save() }', "a.swift").map((f) => f.rule), ["vague-button"]);+ assert.deepStrictEqual(scanSource('Button(onClick = {}) { Text("Submit") }', "a.kt").map((f) => f.rule), ["vague-button"]);+ assert.deepStrictEqual(scanSource('ElevatedButton(onPressed: save, child: Text("Submit"))', "a.dart").map((f) => f.rule), ["vague-button"]);+ // A vague string in the action code is not the label.+ assert.deepStrictEqual(scanSource('Button("Save") { analytics.track("Submit") }', "a.swift"), []);+ assert.deepStrictEqual(scanSource('Button(onClick = { log("Submit") }) { Text("Send order") }', "a.kt"), []);+ assert.deepStrictEqual(scanSource('ElevatedButton(onPressed: () => submitForm("Submit"), child: Text("Send"))', "a.dart"), []);+ assert.deepStrictEqual(scanSource('Button("submit") { save() }', "a.swift").map((f) => f.rule), ["vague-button"]);+ // A bare Text("Submit") outside a button call stays quiet.+ assert.deepStrictEqual(scanSource('Text("Submit")', "a.kt"), []);+ assert.deepStrictEqual(scanSource("Text('Submit')", "a.dart"), []);+ // Specific labels stay quiet.+ assert.deepStrictEqual(scanSource('Button("Save address")', "a.swift"), []);+ assert.deepStrictEqual(scanSource('Text("Save address")', "a.kt"), []);+});+test("transition-all stops at the quote that ends a CSS-in-JS value", () => {// `all` in a later property of a style object is not part of the transition.const pointerEvents = 'const s = { transition: "opacity .2s", pointerEvents: "all" };\n';diff --git a/test/fixtures/slop/Dashboard.swift b/test/fixtures/slop/Dashboard.swiftindex 63df911..32abfa9 100644--- a/test/fixtures/slop/Dashboard.swift+++ b/test/fixtures/slop/Dashboard.swift@@ -12,6 +12,7 @@ struct Dashboard: View {Text(row.title).font(.system(size: 15))}}+ Button("Submit") { save() }}}.background(LinearGradient(colors: [.purple, .indigo], startPoint: .top, endPoint: .bottom))diff --git a/test/fixtures/slop/MainScreen.kt b/test/fixtures/slop/MainScreen.ktindex f72fb6c..cea2004 100644--- a/test/fixtures/slop/MainScreen.kt+++ b/test/fixtures/slop/MainScreen.kt@@ -11,6 +11,7 @@ fun MainScreen(items: List<Item>) {}}Box(Modifier.size(8.dp).background(Color.Green, CircleShape))+ Button(onClick = {}) { Text("Submit") }Icon(Icons.Default.Menu, contentDescription = null)}}diff --git a/test/fixtures/slop/home.dart b/test/fixtures/slop/home.dartindex 7dbcf9b..de6c348 100644--- a/test/fixtures/slop/home.dart+++ b/test/fixtures/slop/home.dart@@ -18,5 +18,6 @@ class Home extends StatelessWidget {}}+final submitButton = ElevatedButton(onPressed: () {}, child: Text("Submit"));final dot = Container(width: 8, height: 8, decoration: BoxDecoration(shape: BoxShape.circle));final t = MediaQuery(data: MediaQueryData(textScaler: TextScaler.noScaling), child: Text('Hi'));