From 2cbf2c071a6764e68ac0470440669652a861197e Mon Sep 17 00:00:00 2001 From: Tom Ratcliffe Date: Tue, 7 Oct 2025 12:14:36 +0100 Subject: [PATCH] Scopes: Remove a rule of hooks warning from scopes (#112103) --- eslint-suppressions.json | 5 ----- .../features/commandPalette/actions/recentScopesActions.ts | 2 +- public/app/features/commandPalette/actions/scopeActions.tsx | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/eslint-suppressions.json b/eslint-suppressions.json index 2612b2c0400..3e9f4e14c96 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -1856,11 +1856,6 @@ "count": 1 } }, - "public/app/features/commandPalette/actions/recentScopesActions.ts": { - "react-hooks/rules-of-hooks": { - "count": 1 - } - }, "public/app/features/commandPalette/actions/scopeActions.tsx": { "react-hooks/rules-of-hooks": { "count": 4 diff --git a/public/app/features/commandPalette/actions/recentScopesActions.ts b/public/app/features/commandPalette/actions/recentScopesActions.ts index 99687d837d3..8cc040e235b 100644 --- a/public/app/features/commandPalette/actions/recentScopesActions.ts +++ b/public/app/features/commandPalette/actions/recentScopesActions.ts @@ -5,7 +5,7 @@ import { useScopesServices } from 'app/features/scopes/ScopesContextProvider'; import { CommandPaletteAction } from '../types'; import { RECENT_SCOPES_PRIORITY } from '../values'; -export function getRecentScopesActions(): CommandPaletteAction[] { +export function useRecentScopesActions(): CommandPaletteAction[] { const services = useScopesServices(); if (!(config.featureToggles.scopeFilters && services)) { diff --git a/public/app/features/commandPalette/actions/scopeActions.tsx b/public/app/features/commandPalette/actions/scopeActions.tsx index 783ec7b1b35..bde41152237 100644 --- a/public/app/features/commandPalette/actions/scopeActions.tsx +++ b/public/app/features/commandPalette/actions/scopeActions.tsx @@ -7,7 +7,7 @@ import { config } from '@grafana/runtime'; import { ScopesRow } from '../ScopesRow'; import { CommandPaletteAction } from '../types'; -import { getRecentScopesActions } from './recentScopesActions'; +import { useRecentScopesActions } from './recentScopesActions'; import { getScopesParentAction, mapScopeNodeToAction, @@ -16,7 +16,7 @@ import { } from './scopesUtils'; export function useRegisterRecentScopesActions() { - const recentScopesActions = getRecentScopesActions(); + const recentScopesActions = useRecentScopesActions(); useRegisterActions(recentScopesActions, [recentScopesActions]); }