From 89d2d34453afde3efa87191c17219b59c8e9a425 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Tue, 25 Aug 2026 17:34:45 -0700 Subject: [PATCH] fix(ui): lint z-index utilities behind arbitrary Tailwind variants The variant prefix pattern only understood word variants, so data-[side=top]:z-50 or [&>*]:z-[5] slipped past the rule. Parse the utility as everything after the last top-level colon (brackets and parens nest) and also strip the important marker. Formats the two files prettier flagged in CI --- .../eslint-rules/no-ad-hoc-z-index.mjs | 29 ++++++++++++++++--- .../components/EntityUsage/TopKeyView.tsx | 5 +++- .../eslint-rules/no-ad-hoc-z-index.test.ts | 24 +++++++++++++-- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/scripts/eslint-rules/no-ad-hoc-z-index.mjs b/ui/litellm-dashboard/scripts/eslint-rules/no-ad-hoc-z-index.mjs index fbe0fdcf7e5..6af86d2c501 100644 --- a/ui/litellm-dashboard/scripts/eslint-rules/no-ad-hoc-z-index.mjs +++ b/ui/litellm-dashboard/scripts/eslint-rules/no-ad-hoc-z-index.mjs @@ -1,9 +1,30 @@ -const AD_HOC_Z = /^(?:[\w-]+:)*-?z-(?:\d+|\[[^\]]*\]|\([^)]*\))$/; -const POPUP_Z = /^(?:[\w-]+:)*z-popup$/; +const AD_HOC_Z = /^-?z-(?:\d+|\[[^\]]*\]|\([^)]*\))$/; + +const OPENERS = { "[": "]", "(": ")" }; + +const utilityOf = (token) => { + const closers = []; + const lastTopLevelColon = [...token].reduce((found, ch, i) => { + if (closers.length > 0 && ch === closers[closers.length - 1]) { + closers.pop(); + return found; + } + if (ch in OPENERS) { + closers.push(OPENERS[ch]); + return found; + } + return ch === ":" && closers.length === 0 ? i : found; + }, -1); + return token + .slice(lastTopLevelColon + 1) + .replace(/^!/, "") + .replace(/!$/, ""); +}; const classify = (token, allowPopupLayer) => { - if (AD_HOC_Z.test(token)) return "adHoc"; - if (!allowPopupLayer && POPUP_Z.test(token)) return "popupReserved"; + const utility = utilityOf(token); + if (AD_HOC_Z.test(utility)) return "adHoc"; + if (!allowPopupLayer && utility === "z-popup") return "popupReserved"; return null; }; diff --git a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx index 975fbd6d623..df1a51d8e38 100644 --- a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx +++ b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/TopKeyView.tsx @@ -246,7 +246,10 @@ const TopKeyView: React.FC = ({ topKeys, teams, showTags = fals )} {isModalOpen && selectedKey && keyData && ( -
+
{/* Close button */}