From d3d30353aa4957518b1b55141a4c0a402a1604c1 Mon Sep 17 00:00:00 2001 From: tin-berri Date: Wed, 5 Aug 2026 11:51:24 -0700 Subject: [PATCH] refactor(ui): remove the three dashboard lint-budget violations added by #35893 (#35960) PR #35929 zeroed the eslint budget headroom while #35893 added UI code in parallel, so staging went over budget by one complexity violation and two no-large-inline-object-arg violations, failing frontend-lint on every UI-touching PR until #35964 reverted the ratchet. This removes the three violations at the source so the budgets can ratchet back down: the submit-blocked-reason chain in add_auto_router_tab moves to a module-level helper, taking the component arrow from complexity 21 to 18, and the two four-property object literals in build_complexity_router_config.test.ts move into named variables. No behavior change; the touched suites pass (101 tests) --- .../add_model/add_auto_router_tab.tsx | 30 +++++++++++++------ .../build_complexity_router_config.test.ts | 10 +++---- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx index a7516b2a3a1..eeabfc681c8 100644 --- a/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx +++ b/ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx @@ -102,6 +102,21 @@ const tierConfigSummary = (tiers: ComplexityTiers): string => { return parts.length > 0 ? parts.join(" ยท ") : "No tiers configured yet"; }; +// Why the submit is unavailable, or null when it is available. The button reads this to disable +// itself and to say what is missing, so the two can never give different answers. Checks the +// config actually being built, not which preset (if any) it came from: a preset only ever +// prefills once (handlePresetChange), and everything after that is edited exactly like Custom. +const getSubmitBlockedReason = ( + config: ComplexityRouterConfigValue, + keywordTierRules: KeywordTierRule[], + referencedModelsParams: Parameters[0], + availableModelSet: Set, +): string | null => + getMissingTiersError(config.tiers) ?? + getTierLabelsError(config.tier_labels) ?? + getKeywordTierRulesError(keywordTierRules) ?? + getReferencedModelsError(referencedModelsParams, availableModelSet); + const AddAutoRouterTab: React.FC = ({ handleOk, accessToken, @@ -222,15 +237,12 @@ const AddAutoRouterTab: React.FC = ({ embeddingModel, }; - // Why the submit is unavailable, or null when it is available. The button reads this to disable - // itself and to say what is missing, so the two can never give different answers. Checks the - // config actually being built, not which preset (if any) it came from: a preset only ever - // prefills once (handlePresetChange), and everything after that is edited exactly like Custom. - const submitBlockedReason = - getMissingTiersError(complexityRouterConfig.tiers) ?? - getTierLabelsError(complexityRouterConfig.tier_labels) ?? - getKeywordTierRulesError(keywordTierRules) ?? - getReferencedModelsError(referencedModelsParams, availableModelSet); + const submitBlockedReason = getSubmitBlockedReason( + complexityRouterConfig, + keywordTierRules, + referencedModelsParams, + availableModelSet, + ); const complexityRouterConfigParams: BuildComplexityRouterConfigParams = { tiers: complexityRouterConfig.tiers, diff --git a/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.test.ts b/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.test.ts index bcbf50bbdea..187ec7070f2 100644 --- a/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.test.ts +++ b/ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.test.ts @@ -437,9 +437,8 @@ describe("getTierLabelsError", () => { }); it("accepts a full distinct rename", () => { - expect( - getTierLabelsError({ SIMPLE: "Cheap", MEDIUM: "Standard", COMPLEX: "Premium", REASONING: "Deep" }), - ).toBeNull(); + const fullRename = { SIMPLE: "Cheap", MEDIUM: "Standard", COMPLEX: "Premium", REASONING: "Deep" }; + expect(getTierLabelsError(fullRename)).toBeNull(); }); it("rejects two tiers sharing a name, which would be ambiguous in the logs", () => { @@ -473,9 +472,8 @@ describe("hydrateTierLabels", () => { }); it("drops non-string and blank values a hand-edited config could hold", () => { - expect(hydrateTierLabels({ SIMPLE: 7, MEDIUM: " ", COMPLEX: null, REASONING: "Deep" })).toEqual({ - REASONING: "Deep", - }); + const handEdited = { SIMPLE: 7, MEDIUM: " ", COMPLEX: null, REASONING: "Deep" }; + expect(hydrateTierLabels(handEdited)).toEqual({ REASONING: "Deep" }); }); it("ignores keys that are not tiers", () => {