Chore: full react hooks eslint compliance (#7040)

This commit is contained in:
shamoon
2026-08-21 14:00:02 -07:00
committed by GitHub
parent 7c26cf6d97
commit 4c361422ca
111 changed files with 1072 additions and 867 deletions
+12 -16
View File
@@ -54,23 +54,19 @@ export default function Component({ service }) {
const { metrics = [], refreshInterval = 10000 } = widget;
let prometheusmetricError;
const metricResults = metrics.slice(0, 4).map((metric) => {
// disable the rule that hooks should not be called from a callback,
// because we don't need a strong guarantee of hook execution order here.
// eslint-disable-next-line react-hooks/rules-of-hooks
const { data, error } = useWidgetAPI(widget, "query", {
query: metric.query,
refreshInterval: Math.max(1000, metric.refreshInterval ?? refreshInterval),
});
return { key: metric.key ?? metric.label, data, error };
});
const prometheusmetricData = new Map(
metrics.slice(0, 4).map((metric) => {
// disable the rule that hooks should not be called from a callback,
// because we don't need a strong guarantee of hook execution order here.
// eslint-disable-next-line react-hooks/rules-of-hooks
const { data: resultData, error: resultError } = useWidgetAPI(widget, "query", {
query: metric.query,
refreshInterval: Math.max(1000, metric.refreshInterval ?? refreshInterval),
});
if (resultError) {
prometheusmetricError = resultError;
}
return [metric.key ?? metric.label, resultData];
}),
);
const prometheusmetricError = metricResults.find(({ error }) => error)?.error;
const prometheusmetricData = new Map(metricResults.map(({ key, data }) => [key, data]));
if (prometheusmetricError) {
return <Container service={service} error={prometheusmetricError} />;