From d9aaf1b1aead938ce43701438ec11910072fa57e Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Wed, 1 Jul 2026 18:01:30 +0200 Subject: [PATCH 1/2] chore(eslint): enable @tanstack/query/exhaustive-deps rule Fix 4 violations where queryFn referenced variables not in queryKey: - advisories.ts, sboms.ts, sbom-groups.ts: move requestParamsQuery() destructuring inside queryFn so derived variables are local - vulnerabilities.ts: inline the API call to eliminate the chunks closure dependency Part of #1128. Co-Authored-By: Claude Opus 4.6 (1M context) --- client/src/app/queries/advisories.ts | 2 +- client/src/app/queries/sbom-groups.ts | 12 +++---- client/src/app/queries/sboms.ts | 9 ++--- client/src/app/queries/vulnerabilities.ts | 43 ++++++++++------------- eslint.config.mjs | 1 - 5 files changed, 31 insertions(+), 36 deletions(-) diff --git a/client/src/app/queries/advisories.ts b/client/src/app/queries/advisories.ts index bacfed74f..0687e752b 100644 --- a/client/src/app/queries/advisories.ts +++ b/client/src/app/queries/advisories.ts @@ -60,12 +60,12 @@ export const useFetchAdvisories = ( labels: Label[] = [], disableQuery = false, ) => { - const { q, ...rest } = requestParamsQuery(params); const labelQuery = labelRequestParamsQuery(labels); const { data, isLoading, error, refetch } = useQuery({ queryKey: [AdvisoriesQueryKey, params, labelQuery], queryFn: () => { + const { q, ...rest } = requestParamsQuery(params); return listAdvisories({ client, query: { diff --git a/client/src/app/queries/sbom-groups.ts b/client/src/app/queries/sbom-groups.ts index 3f039ccd7..741429e89 100644 --- a/client/src/app/queries/sbom-groups.ts +++ b/client/src/app/queries/sbom-groups.ts @@ -67,20 +67,20 @@ export const useFetchSBOMGroups = ( > = {}, enabled = true, ) => { - const { q, ...rest } = requestParamsQuery(params); - const parentQuery = parentId ? `parent=${parentId}` : ""; - const { data, isLoading, error, refetch } = useQuery({ queryKey: [SBOMGroupsQueryKey, parentId, { params, extraQueryParams }], - queryFn: () => - listSbomGroups({ + queryFn: () => { + const { q, ...rest } = requestParamsQuery(params); + const parentQuery = parentId ? `parent=${parentId}` : ""; + return listSbomGroups({ client, query: { ...rest, ...extraQueryParams, q: [q, parentQuery].filter((e) => e).join("&"), }, - }), + }); + }, enabled, }); diff --git a/client/src/app/queries/sboms.ts b/client/src/app/queries/sboms.ts index e03a9faff..b3c1f5fad 100644 --- a/client/src/app/queries/sboms.ts +++ b/client/src/app/queries/sboms.ts @@ -62,20 +62,21 @@ export const useFetchSBOMs = ( labels: Label[] = [], disableQuery = false, ) => { - const { q, ...rest } = requestParamsQuery(params); const labelQuery = labelRequestParamsQuery(labels); const { data, isLoading, error, refetch } = useQuery({ queryKey: [SBOMsQueryKey, groupId, params, labelQuery], - queryFn: () => - listSboms({ + queryFn: () => { + const { q, ...rest } = requestParamsQuery(params); + return listSboms({ client, query: { ...rest, group: groupId ? [groupId] : [], q: [q, labelQuery].filter((e) => e).join("&"), }, - }), + }); + }, enabled: !disableQuery, }); return { diff --git a/client/src/app/queries/vulnerabilities.ts b/client/src/app/queries/vulnerabilities.ts index 9d42224da..32342e238 100644 --- a/client/src/app/queries/vulnerabilities.ts +++ b/client/src/app/queries/vulnerabilities.ts @@ -41,32 +41,27 @@ export const useFetchVulnerabilities = ( }; export const useFetchVulnerabilitiesByPackageIds = (ids: string[]) => { - const chunks = { - ids: ids.reduce((chunks, item, index) => { - if (index % 100 === 0) { - chunks.push([item]); - } else { - chunks[chunks.length - 1].push(item); - } - return chunks; - }, []), - dataResolver: async (ids: string[]) => { - const response = await analyzeV3({ - client, - body: { purls: ids }, - }); - return response.data; - }, - }; + const chunkedIds = ids.reduce((chunks, item, index) => { + if (index % 100 === 0) { + chunks.push([item]); + } else { + chunks[chunks.length - 1].push(item); + } + return chunks; + }, []); const userQueries = useQueries({ - queries: chunks.ids.map((ids) => { - return { - queryKey: [VulnerabilitiesQueryKey, ids], - queryFn: () => chunks.dataResolver(ids), - retry: false, - }; - }), + queries: chunkedIds.map((chunkIds) => ({ + queryKey: [VulnerabilitiesQueryKey, chunkIds], + queryFn: async () => { + const response = await analyzeV3({ + client, + body: { purls: chunkIds }, + }); + return response.data; + }, + retry: false, + })), }); const isFetching = userQueries.some(({ isFetching }) => isFetching); diff --git a/eslint.config.mjs b/eslint.config.mjs index 4dce37c2f..ab183924d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -44,7 +44,6 @@ export default defineConfig([ "@eslint-react/exhaustive-deps": "off", "@eslint-react/no-nested-component-definitions": "off", "@tanstack/query/prefer-query-options": "off", - "@tanstack/query/exhaustive-deps": "off", "@tanstack/query/no-void-query-fn": "off", }, ignores: [ From 43ad8657e75cc119d390ed195cec95bd6a6ec36a Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Thu, 2 Jul 2026 11:51:05 +0200 Subject: [PATCH 2/2] fix: merge main --- client/src/app/queries/vulnerabilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/queries/vulnerabilities.ts b/client/src/app/queries/vulnerabilities.ts index 32342e238..4fff040db 100644 --- a/client/src/app/queries/vulnerabilities.ts +++ b/client/src/app/queries/vulnerabilities.ts @@ -58,7 +58,7 @@ export const useFetchVulnerabilitiesByPackageIds = (ids: string[]) => { client, body: { purls: chunkIds }, }); - return response.data; + return response.data ?? null; }, retry: false, })),