svelte state_referenced_locally warning fixes

- change to derived where possible
- suppress warning elsewhere
- discussion here: sveltejs/svelte/issues/17289
This commit is contained in:
Christoph Kluge
2026-01-15 18:17:45 +01:00
parent cd3d133f0d
commit faacf3f343
41 changed files with 167 additions and 127 deletions

View File

@@ -45,7 +45,6 @@
const statsPattern = /(.*)-stat$/;
const resampleConfig = getContext("resampling") || null;
const resampleDefault = resampleConfig ? Math.max(...resampleConfig.resolutions) : 0;
const unit = (metricUnit?.prefix ? metricUnit.prefix : "") + (metricUnit?.base ? metricUnit.base : "");
const subQuery = gql`
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!, $selectedResolution: Int) {
singleUpdate: jobMetrics(id: $dbid, metrics: $selectedMetrics, scopes: $selectedScopes, resolution: $selectedResolution) {
@@ -79,14 +78,14 @@
`;
/* State Init */
let requestedScopes = $state(presetScopes);
let selectedResolution = $state(resampleDefault);
let selectedHost = $state(null);
let zoomState = $state(null);
let thresholdState = $state(null);
/* Derived */
let requestedScopes = $derived(presetScopes);
const unit = $derived.by(() => { return (metricUnit?.prefix ? metricUnit.prefix : "") + (metricUnit?.base ? metricUnit.base : "")});
const metricData = $derived(queryStore({
client: client,
query: subQuery,

View File

@@ -25,9 +25,13 @@
} = $props();
/* State Init */
// svelte-ignore state_referenced_locally
let sortedHosts = $state(hosts);
// svelte-ignore state_referenced_locally
let sorting = $state(setupSorting(selectedMetrics));
// svelte-ignore state_referenced_locally
let availableScopes = $state(setupAvailable(jobStats));
// svelte-ignore state_referenced_locally
let selectedScopes = $state(setupSelected(availableScopes));
/* Derived Init */