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): match every style of the hamburger icon in drawer-nav (#146) (#152)

Pure Tech734dd68d569c
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 88d52f9..126d2c9 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -893,7 +893,7 @@ const rules = [
message: "Hamburger menu or navigation drawer. It hides the top destinations behind a tap.",
fix: "Ask first. Use tabs for three to five peer destinations; keep a drawer only for many destinations or a large-screen rail.",
find({ code }) {
- const re = /["']line\.(?:3\.horizontal|horizontal\.3)["']|\bIcons\.(?:Default\.|Filled\.|Outlined\.|Rounded\.|Sharp\.)?Menu\b|\bIcons\.menu\b|name=["']menu(?:-outline)?["']|\bcreateDrawerNavigator\b|from\s+["']expo-router\/drawer["']|\bModalNavigationDrawer\b|\bdrawer:\s*(?:const\s+)?\w*Drawer\b|<ion-menu\b/;
+ const re = /["']line\.(?:3\.horizontal|horizontal\.3)["']|\bIcons\.(?:Default\.|Filled\.|Outlined\.|Rounded\.|Sharp\.)?Menu\b|\bIcons\.menu(?:_rounded|_outlined|_sharp)?\b|name=["']menu(?:-outline|-sharp)?["']|\bcreateDrawerNavigator\b|from\s+["']expo-router\/drawer["']|\bModalNavigationDrawer\b|\bdrawer:\s*(?:const\s+)?\w*Drawer\b|<ion-menu\b/;
const first = matches(re, code).next();
return first.done ? [] : [first.value.index];
},
diff --git a/test/detect.test.js b/test/detect.test.js
index de270cc..d9fd94d 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1415,3 +1415,14 @@ test("drawer-nav catches both line.3.horizontal and older line.horizontal.3 SF S
[],
);
});
+
+test("drawer-nav catches every style of the hamburger icon (issue #146)", () => {
+ const lines = (src, file) => scanSource(src, file).filter((f) => f.rule === "drawer-nav").map((f) => f.line);
+ for (const icon of ["menu_rounded", "menu_outlined", "menu_sharp"]) {
+ assert.deepStrictEqual(lines(`IconButton(icon: const Icon(Icons.${icon}), onPressed: openDrawer)\n`, "header.dart"), [1], icon);
+ }
+ assert.deepStrictEqual(lines('<Ionicons name="menu-sharp" size={24} />\n', "Header.tsx"), [1]);
+ // menu_book is a different icon.
+ assert.deepStrictEqual(lines("Icon(Icons.menu_book)\n", "header.dart"), []);
+ assert.deepStrictEqual(lines('<Ionicons name="menu-sharp-outline" />\n', "Header.tsx"), []);
+});