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(detect): flag Flutter accent colors in slop-gradient (#172) (#192)

Papito084d02ea9744b8e
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 8075ca4..0619260 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -210,8 +210,9 @@ function isSaturated(hex) {
}
// Also the CSS named colors in that band (rebeccapurple, hotpink, ...), which a
-// plain \bpurple\b or \bpink\b does not reach, and UIKit system colors (.systemPurple, ...).
-const SLOP_COLOR_NAME = /(?:\.|Colors\.|Color\.|\b)(?:system)?(purple|deepPurple|indigo|violet|pink|magenta|fuchsia|rebeccapurple|mediumpurple|blueviolet|darkviolet|darkorchid|mediumorchid|hotpink|deeppink|mediumvioletred)\b/i;
+// plain \bpurple\b or \bpink\b does not reach, UIKit system colors (.systemPurple, ...)
+// and Flutter accent swatches (Colors.purpleAccent, ...).
+const SLOP_COLOR_NAME = /(?:\.|Colors\.|Color\.|\b)(?:system)?(purple|deepPurple|indigo|violet|pink|magenta|fuchsia|rebeccapurple|mediumpurple|blueviolet|darkviolet|darkorchid|mediumorchid|hotpink|deeppink|mediumvioletred)(?:Accent)?\b/i;
// Replace comments with spaces, keeping offsets and newlines, so rules never
// match commented-out code. Strings are kept.
diff --git a/test/detect.test.js b/test/detect.test.js
index bc1d03c..923664f 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1803,6 +1803,26 @@ test("slop-gradient reads Flutter Color.fromARGB and Color.fromRGBO stops (issue
for (const stops of quiet) assert.deepStrictEqual(rulesFor(gradient(stops)), [], stops);
});
+test("slop-gradient reads Flutter accent colors like Colors.purpleAccent (issue #172)", () => {
+ const rulesFor = (src) => scanSource(src, "hero.dart").map((f) => f.rule).filter((r) => r === "slop-gradient");
+ const gradient = (stops) => `Container(decoration: BoxDecoration(gradient: LinearGradient(colors: [${stops}])))\n`;
+ const flagged = [
+ "Colors.purpleAccent, Colors.pinkAccent",
+ "Colors.deepPurpleAccent, Colors.pinkAccent",
+ "Colors.indigoAccent, Colors.white",
+ "Colors.purpleAccent.shade200, Colors.pinkAccent.shade400",
+ "Colors.deepPurpleAccent.shade100, Colors.white",
+ ];
+ for (const stops of flagged) assert.deepStrictEqual(rulesFor(gradient(stops)), ["slop-gradient"], stops);
+
+ const quiet = [
+ "Colors.tealAccent, Colors.lightBlueAccent",
+ "Colors.greenAccent, Colors.cyanAccent",
+ "Colors.orangeAccent, Colors.yellowAccent",
+ ];
+ for (const stops of quiet) assert.deepStrictEqual(rulesFor(gradient(stops)), [], stops);
+});
+
test("slop-gradient reads SwiftUI Color(red:green:blue:) stops (issue #162)", () => {
const rulesFor = (src) => scanSource(src, "Hero.swift").map((f) => f.rule).filter((r) => r === "slop-gradient");
const gradient = (stops) => `LinearGradient(colors: [${stops}], startPoint: .leading, endPoint: .trailing)\n`;