8000 [UI v2] Turn on linting with biome and fix lint errors (#17748) · CodersSampling/prefect@3fc1013 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fc1013

Browse files
authored
[UI v2] Turn on linting with biome and fix lint errors (PrefectHQ#17748)
1 parent 4100d4e commit 3fc1013

File tree

194 files changed

+537
-482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+537
-482
lines changed

ui-v2/biome.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@
3232
]
3333
},
3434
"linter": {
35-
"enabled": false,
35+
"enabled": true,
3636
"rules": {
37-
"recommended": true
37+
"recommended": true,
38+
"correctness": {
39+
"noUnusedVariables": "error",
40+
"noUnusedImports": "error",
41+
"noUnusedFunctionParameters": "error"
42+
}
3843
}
3944
},
4045
"javascript": {

ui-v2/public/mockServiceWorker.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ const INTEGRITY_CHECKSUM = "00729d72e3b82faf54ca8b9621dbb96f";
1212
const IS_MOCKED_RESPONSE = Symbol("isMockedResponse");
1313
const activeClientIds = new Set();
1414

15-
self.addEventListener("install", function () {
15+
self.addEventListener("install", () => {
1616
self.skipWaiting();
1717
});
1818

19-
self.addEventListener("activate", function (event) {
19+
self.addEventListener("activate", (event) => {
2020
event.waitUntil(self.clients.claim());
2121
});
2222

23-
self.addEventListener("message", async function (event) {
23+
self.addEventListener("message", async (event) => {
2424
const clientId = event.source.id;
2525

2626
if (!clientId || !self.clients) {
@@ -93,7 +93,7 @@ self.addEventListener("message", async function (event) {
9393
}
9494
});
9595

96-
self.addEventListener("fetch", function (event) {
96+
self.addEventListener("fetch", (event) => {
9797
const { request } = event;
9898

9999
// Bypass navigation requests.
@@ -127,7 +127,7 @@ async function handleRequest(event, requestId) {
127127
// Ensure MSW is active and ready to handle the message, otherwise
128128
// this message will pend indefinitely.
129129
if (client && activeClientIds.has(client.id)) {
130-
(async function () {
130+
(async () => {
131131
const responseClone = response.clone();
132132

133133
sendToClient(
@@ -272,7 +272,7 @@ function sendToClient(client, message, transferrables = []) {
272272
const channel = new MessageChannel();
273273

274274
channel.port1.onmessage = (event) => {
275-
if (event.data && event.data.error) {
275+
if (event.data?.error) {
276276
return reject(event.data.error);
277277
}
278278

ui-v2/src/api/artifacts/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { keepPreviousData, queryOptions } from "@tanstack/react-query";
2-
import { components } from "../prefect";
2+
import type { components } from "../prefect";
33
import { getQueryService } from "../service";
44

55
export type Artifact = components["schemas"]["Artifact"];
@@ -102,7 +102,7 @@ export const buildCountArtifactsQuery = (
102102
},
103103
) =>
104104
queryOptions({
105-
queryKey: queryKeyFactory["count"](filter),
105+
queryKey: queryKeyFactory.count(filter),
106106
queryFn: async () => {
107107
const res = await getQueryService().POST("/artifacts/count", {
108108
body: filter,

ui-v2/src/api/artifacts/use-get-artifacts-flow-task-runs/use-get-artifacts-flow-task-runs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { buildFilterFlowRunsQuery } from "@/api/flow-runs";
22
import { buildListTaskRunsQuery } from "@/api/task-runs";
33
import { useQueries, useQuery } from "@tanstack/react-query";
44
import {
5-
ArtifactWithFlowRunAndTaskRun,
6-
ArtifactsFilter,
5+
type ArtifactWithFlowRunAndTaskRun,
6+
type ArtifactsFilter,
77
buildGetArtifactQuery,
88
buildListArtifactsQuery,
99
} from "..";

ui-v2/src/api/automations/use-get-automation-action-resources/use-get-automation-action-resources.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { renderHook, waitFor } from "@testing-library/react";
1515
import { buildApiUrl, createWrapper, server } from "@tests/utils";
1616
import { http, HttpResponse } from "msw";
1717
import { describe, expect, it } from "vitest";
18-
import { Automation } from "../automations";
18+
import type { Automation } from "../automations";
1919
import {
2020
getResourceSets,
2121
useGetAutomationActionResources,

ui-v2/src/api/automations/use-get-automation-action-resources/use-get-automation-action-resources.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Automation, buildGetAutomationQuery } from "@/api/automations";
1+
import { type Automation, buildGetAutomationQuery } from "@/api/automations";
22
import { buildListFilterBlockDocumentsQuery } from "@/api/block-documents";
33
import { buildFilterDeploymentsQuery } from "@/api/deployments";
44
import { buildFilterWorkPoolsQuery } from "@/api/work-pools";
@@ -125,11 +125,11 @@ const useListAutomationsQueries = (automationIds: Array<string>) =>
125125
),
126126
combine: (results) => {
127127
const retMap = new Map<string, Automation>();
128-
results.forEach((result) => {
128+
for (const result of results) {
129129
if (result.data) {
130130
retMap.set(result.data.id, result.data);
131131
}
132-
});
132+
}
133133
return {
134134
data: retMap,
135135
loading: results.some((result) => result.isLoading),
@@ -144,46 +144,47 @@ export const getResourceSets = (actions: Automation["actions"]) => {
144144
const workPoolIds = new Set<string>();
145145
const workQueueIds = new Set<string>();
146146

147-
actions.forEach((action) => {
147+
for (const action of actions) {
148148
switch (action.type) {
149149
case "run-deployment":
150150
case "pause-deployment":
151151
case "resume-deployment":
152152
if (action.deployment_id) {
153153
deploymentIds.add(action.deployment_id);
154154
}
155-
return;
155+
break;
156156
case "pause-work-queue":
157157
case "resume-work-queue":
158158
if (action.work_queue_id) {
159159
workQueueIds.add(action.work_queue_id);
160160
}
161-
return;
161+
break;
162162
case "pause-automation":
163163
case "resume-automation":
164164
if (action.automation_id) {
165165
automationIds.add(action.automation_id);
166166
}
167-
return;
167+
break;
168168
case "pause-work-pool":
169169
case "resume-work-pool":
170170
if (action.work_pool_id) {
171171
workPoolIds.add(action.work_pool_id);
172172
}
173-
return;
173+
break;
174174
case "send-notification":
175175
case "call-webhook":
176-
blockDocumentIds.add(action.block_document_id);
177-
return;
178-
case "do-nothing":
179-
case "cancel-flow-run":
180-
case "change-flow-run-state":
181-
case "suspend-flow-run":
182-
case "resume-flow-run":
183-
default:
184-
return;
176+
if (action.block_document_id) {
177+
blockDocumentIds.add(action.block_document_id);
178+
}
179+
break;
180+
// TODO: add these back when the corresponding actions are implemented
181+
// case "do-nothing":
182+
// case "cancel-flow-run":
183+
// case "change-flow-run-state":
184+
// case "suspend-flow-run":
185+
// case "resume-flow-run":
185186
}
186-
});
187+
}
187188

188189
return {
189190
automationIds,
@@ -198,8 +199,8 @@ function listToMap<T extends { id: string }>(
198199
list: T[] | undefined,
199200
): Map<T["id"], T> {
200201
const map = new Map<T["id"], T>();
201-
list?.forEach((item) => {
202+
for (const item of list ?? []) {
202203
map.set(item.id, item);
203-
});
204+
}
204205
return map;
205206
}

ui-v2/src/api/deployments/use-list-deployments-with-flows/use-list-deployments-with-flows.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
2-
Deployment,
3-
DeploymentsPaginationFilter,
2+
type Deployment,
3+
type DeploymentsPaginationFilter,
44
buildPaginateDeploymentsQuery,
55
} from "@/api/deployments";
6-
import { Flow, buildListFlowsQuery } from "@/api/flows";
6+
import { type Flow, buildListFlowsQuery } from "@/api/flows";
77
import { useQuery } from "@tanstack/react-query";
88
import { useMemo } from "react";
99

ui-v2/src/api/flow-runs/use-filter-flow-runs-with-flows/use-filter-flow-runs-with-flows.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { FlowRunsFilter, buildFilterFlowRunsQuery } from "@/api/flow-runs";
2-
import { Flow, buildListFlowsQuery } from "@/api/flows";
1+
import { type FlowRunsFilter, buildFilterFlowRunsQuery } from "@/api/flow-runs";
2+
import { type Flow, buildListFlowsQuery } from "@/api/flows";
33
import { useQuery } from "@tanstack/react-query";
44
import { useMemo } from "react";
55

ui-v2/src/api/flow-runs/use-paginate-flow-runs-with-flows/use-paginate-flow-runs-with-flows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
type FlowRunsPaginateFilter,
44
buildPaginateFlowRunsQuery,
55
} from "@/api/flow-runs";
6-
import { Flow, buildListFlowsQuery } from "@/api/flows";
6+
import { type Flow, buildListFlowsQuery } from "@/api/flows";
77
import { useQuery } from "@tanstack/react-query";
88
import { useMemo } from "react";
99

ui-v2/src/api/flows/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { components } from "@/api/prefect";
1+
import type { components } from "@/api/prefect";
22
import { getQueryService } from "@/api/service";
33
import {
44
keepPreviousData,
< 3197 /div>

0 commit comments

Comments
 (0)
0