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 Angular Material mat-sidenav and mat-drawer (#319)

Shreeyassh12c35d601ff1
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 1afa6a4..b4b9258 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|\bdrawer:\s*(?:const\s+)?\w*Drawer\b|<ion-menu\b|<IonMenu(?:Button|Toggle)?\b|<(?:q-drawer|QDrawer)(?![\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["']|\bModalNavigationDrawer\b|\bdrawer:\s*(?:const\s+)?\w*Drawer\b|<ion-menu\b|<IonMenu(?:Button|Toggle)?\b|<(?:q-drawer|QDrawer)(?![\w-])|<(?:mat-sidenav|mat-drawer)(?![\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 167e999..74b9d75 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -3101,3 +3101,31 @@ test("sparkle-icon catches Primer SparkleFillIcon and SparklesFillIcon (issue #3
].join("\n");
assert.deepStrictEqual(sparkleLines(ask, "Ask.tsx"), [1, 3, 4]);
});
+
+test("drawer-nav catches Angular Material mat-sidenav and mat-drawer (issue #300)", () => {
+ const drawerLines = (src, file = "shell.component.html") =>
+ scanSource(src, file, { platform: "mobile" }).filter((f) => f.rule === "drawer-nav").map((f) => f.line);
+
+ const repro = [
+ "<mat-sidenav-container>",
+ ' <mat-sidenav mode="side" opened>',
+ " <mat-nav-list>Menu</mat-nav-list>",
+ " </mat-sidenav>",
+ " <mat-sidenav-content>Main</mat-sidenav-content>",
+ "</mat-sidenav-container>",
+ ].join("\n");
+ assert.deepStrictEqual(drawerLines(repro), [2]);
+
+ const drawer = [
+ "<mat-drawer-container>",
+ ' <mat-drawer mode="side">Menu</mat-drawer>',
+ " <mat-drawer-content>Main</mat-drawer-content>",
+ "</mat-drawer-container>",
+ ].join("\n");
+ assert.deepStrictEqual(drawerLines(drawer), [2]);
+
+ assert.deepStrictEqual(drawerLines("<mat-tab-group><mat-tab label='Home'></mat-tab></mat-tab-group>\n"), []);
+
+ assert.deepStrictEqual(drawerLines("<mat-sidenav-container>\n <mat-sidenav-content>Main</mat-sidenav-content>\n</mat-sidenav-container>\n"), []);
+ assert.deepStrictEqual(drawerLines("<mat-drawer-container>\n <mat-drawer-content>Main</mat-drawer-content>\n</mat-drawer-container>\n"), []);
+});