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(drawer-nav): detect Compose DismissibleNavigationDrawer (#330)

Jay19fb0abae127
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index ebd07fc..ec0e0f3 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1192,7 +1192,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(?:_rounded|_outlined|_sharp)?\b|\b(?:name|icon)=["']menu(?:-outline|-sharp)?["']|\bcreateDrawerNavigator\b|from\s+["']expo-router\/drawer["']|\bModalNavigationDrawer\b|\b(?:drawer|endDrawer):\s*(?:const\s+)?\w*Drawer\b|<ion-menu\b|<IonMenu(?:Button|Toggle)?\b|<(?:q-drawer|QDrawer)(?![\w-])|<(?:mat-sidenav|mat-drawer)(?![\w-])|<(?:v-navigation-drawer|VNavigationDrawer)(?![\w-])|\bBars3(?:BottomLeft|BottomRight|CenterLeft)?Icon\b|\bIconMenu2\b/;
+ const re = /["']line\.(?:3\.horizontal|horizontal\.3)["']|\bIcons\.(?:Default\.|Filled\.|Outlined\.|Rounded\.|Sharp\.)?Menu\b|\bIcons\.menu(?:_rounded|_outlined|_sharp)?\b|\b(?:name|icon)=["']menu(?:-outline|-sharp)?["']|\bcreateDrawerNavigator\b|from\s+["']expo-router\/drawer["']|\b(?:Modal|Dismissible)NavigationDrawer\s*\(|\b(?:drawer|endDrawer):\s*(?:const\s+)?\w*Drawer\b|<ion-menu\b|<IonMenu(?:Button|Toggle)?\b|<(?:q-drawer|QDrawer)(?![\w-])|<(?:mat-sidenav|mat-drawer)(?![\w-])|<(?:v-navigation-drawer|VNavigationDrawer)(?![\w-])|\bBars3(?:BottomLeft|BottomRight|CenterLeft)?Icon\b|\bIconMenu2\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 4bedb7a..6bfb54f 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -3221,3 +3221,47 @@ test("drawer-nav catches Flutter's endDrawer, not a bottom navigation bar (issue
// Quiet case: a Scaffold with only a bottom navigation bar
assert.deepStrictEqual(lines("Scaffold(\n bottomNavigationBar: NavigationBar(destinations: tabs),\n body: const Text('Home'),\n)\n"), []);
});
+
+test("drawer-nav catches Compose DismissibleNavigationDrawer and ModalNavigationDrawer, not PermanentNavigationDrawer (issue #328)", () => {
+ const drawerLines = (src, file = "Home.kt") =>
+ scanSource(src, file, { kind: "mobile" }).filter((f) => f.rule === "drawer-nav").map((f) => f.line);
+
+ const dismissible = [
+ "@Composable",
+ "fun Home() {",
+ ' DismissibleNavigationDrawer(drawerContent = { Text("Menu") }) {',
+ ' Text("Home")',
+ " }",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(drawerLines(dismissible), [3]);
+
+ const modal = dismissible.replace("DismissibleNavigationDrawer", "ModalNavigationDrawer");
+ assert.deepStrictEqual(drawerLines(modal), [3]);
+
+ const permanent = dismissible.replace("DismissibleNavigationDrawer", "PermanentNavigationDrawer");
+ assert.deepStrictEqual(drawerLines(permanent), []);
+
+ const importOnly = [
+ "import androidx.compose.material3.DismissibleNavigationDrawer",
+ "import androidx.compose.material3.PermanentNavigationDrawer",
+ "@Composable",
+ "fun Home() {",
+ ' PermanentNavigationDrawer(drawerContent = { Text("Menu") }) {',
+ ' Text("Home")',
+ " }",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(drawerLines(importOnly), []);
+ assert.deepStrictEqual(
+ scanSource(dismissible, "Home.kt", { kind: "web" }).filter((f) => f.rule === "drawer-nav"),
+ [],
+ );
+
+ const unusedImport = [
+ "import androidx.compose.material3.DismissibleNavigationDrawer",
+ "@Composable",
+ "fun Home() { Text(\"Home\") }",
+ ].join("\n");
+ assert.deepStrictEqual(drawerLines(unusedImport), []);
+});