Skip to content

Commit 30b82e4

Browse files
authored
Update Biome to v2 (#9244)
This PR updates `biome` to version 2.x. I followed the [upgrade guide](https://biomejs.dev/guides/upgrade-to-biome-v2/) and then manually solved all new errors caused by new default rules. The `biome.json` config file was auto-updated by the `biome migrate` command as instructed by the migration guide. Notes: - Each fix to a rule is one self-contained commit, which might be useful for code review. - I disabled the linting rule [`no-static-element-interactions`](https://biomejs.dev/linter/rules/no-static-element-interactions/ ). Otherwise, every `<div onClick=...>` or `<a onClick=...>` is flagged. Suppresses 64 errors. - Configured linting rule `[useExhaustiveDependencies](https://biomejs.dev/linter/rules/use-exhaustive-dependencies/)` as warning. Otherwise, a lot of `useEffect` would be marked as errors. ### Steps to test: - CI linting, testing should be enough ### TODOs: - Consider removing the following rules in a follow up PR - [`lint/complexity/noUselessFragments`](https://biomejs.dev/linter/rules/no-useless-fragments/#_top) ### Issues: - Contributes to #9243 ------ (Please delete unneeded items, merge only when none are left open) - [ ] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`) - [ ] Added migration guide entry if applicable (edit the same file as for the changelog) - [ ] Updated [documentation](../blob/master/docs) if applicable - [ ] Adapted [wk-libs python client](https://github.com/scalableminds/webknossos-libs/tree/master/webknossos/webknossos/client) if relevant API parts change - [ ] Removed dev-only changes like prints and application.conf edits - [ ] Considered [common edge cases](../blob/master/.github/common_edge_cases.md) - [ ] Needs datastore update after deployment
1 parent 9281299 commit 30b82e4

File tree

356 files changed

+1573
-1519
lines changed

Some content is hidden

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

356 files changed

+1573
-1519
lines changed

biome.json renamed to biome.jsonc

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3-
"organizeImports": {
4-
"enabled": true,
5-
"ignore": [
6-
"frontend/javascripts/test/*",
7-
"frontend/javascripts/viewer/model/helpers/shader_editor.ts",
8-
"**/__snapshots__/**"
3+
"files": {
4+
"includes": [
5+
"**",
6+
"!**/libs/stl_exporter.ts",
7+
"!**/libs/DRACOLoader.ts",
8+
"!**/libs/DRACOWorker.worker.js",
9+
"!**/libs/BufferGeometryUtils.ts",
10+
"!**/libs/parse_stl_buffer.ts",
11+
"!**/libs/trackball_controls.ts",
12+
"!**/libs/fps_meter.ts",
13+
"!**/*.d.ts",
14+
"!**/*.json",
15+
"!**/*.jsonc",
16+
"!**/*.ts.snap",
17+
"!**/__snapshots__",
18+
"!**/frontend/javascripts/test/snapshots"
919
]
1020
},
21+
"assist": {
22+
"actions": {
23+
"source": {
24+
"organizeImports": "on"
25+
}
26+
}
27+
},
1128
"linter": {
1229
"enabled": true,
13-
"ignore": [
14-
"libs/keyboard.ts",
15-
"libs/stl_exporter.ts",
16-
"libs/DRACOLoader.ts",
17-
"libs/DRACOWorker.worker.js",
18-
"libs/BufferGeometryUtils.ts",
19-
"libs/fps_meter.ts",
20-
"libs/parse_stl_buffer.ts",
21-
"libs/trackball_controls.ts",
22-
"*.d.ts",
23-
"frontend/javascripts/test/snapshots/*",
24-
"**/__snapshots__/**"
30+
"includes": [
31+
"!**/libs/keyboard.ts",
32+
"!**/libs/stl_exporter.ts",
33+
"!**/libs/DRACOLoader.ts",
34+
"!**/libs/DRACOWorker.worker.js",
35+
"!**/libs/BufferGeometryUtils.ts",
36+
"!**/libs/fps_meter.ts",
37+
"!**/libs/parse_stl_buffer.ts",
38+
"!**/libs/trackball_controls.ts",
39+
"!**/*.d.ts",
40+
"!**/*.json",
41+
"!**/frontend/javascripts/test/snapshots/**/*",
42+
"**"
2543
],
2644
"rules": {
2745
"recommended": true,
2846
"style": {
29-
"useShorthandArrayType": "off",
3047
"useBlockStatements": "off",
3148
"noNegationElse": "off",
3249
"noImplicitBoolean": "off",
@@ -41,13 +58,26 @@
4158
"useDefaultParameterLast": "off",
4259
"useAsConstAssertion": "off",
4360
"noNonNullAssertion": "off",
44-
"noNamespaceImport": "error"
61+
"useConsistentArrayType": {
62+
"level": "off",
63+
"options": {
64+
"syntax": "shorthand"
65+
}
66+
},
67+
"noRestrictedImports": {
68+
"level": "error",
69+
"options": {
70+
"paths": {
71+
"lodash": "Import <method> from 'lodash/<method>' instead."
72+
}
73+
}
74+
}
4575
},
4676
"complexity": {
47-
"useSimplifiedLogicExpression": "off",
77+
"useSimplifiedLogicExpression": "off", // TODO: consider removing
4878
"noForEach": "off",
4979
"noBannedTypes": "error",
50-
"noUselessFragments": "off",
80+
"noUselessFragments": "off", // TODO: consider removing
5181
"useLiteralKeys": "off",
5282
"useArrowFunction": "off",
5383
"noStaticOnlyClass": "off",
@@ -60,61 +90,48 @@
6090
"useKeyWithClickEvents": "off",
6191
"useIframeTitle": "off",
6292
"noAriaHiddenOnFocusable": "off",
63-
"noLabelWithoutControl": "off"
93+
"noLabelWithoutControl": "off",
94+
"noStaticElementInteractions": "off"
6495
},
6596
"performance": {
66-
"noDelete": "off"
97+
"noDelete": "off",
98+
"noNamespaceImport": "error"
6799
},
68100
"correctness": {
69101
"noUnusedVariables": "error",
70102
"noUnusedImports": "error",
71103
"noRenderReturnValue": "off",
72-
"useHookAtTopLevel": "error"
104+
"useHookAtTopLevel": "error",
105+
"useExhaustiveDependencies": "warn" // TODO: consider turning this into an error
73106
},
74107
"suspicious": {
75108
"noExplicitAny": "off",
76109
"noAsyncPromiseExecutor": "off",
77110
"noShadowRestrictedNames": "off",
78111
"noImplicitAnyLet": "off",
79112
"noConfusingVoidType": "off",
80-
"noGlobalIsNan": "off",
113+
"noGlobalIsNan": "off", // TODO: consider turning this into an error
81114
"noArrayIndexKey": "off",
82115
"noConstEnum": "off",
83116
"noRedeclare": "off",
84117
"noFallthroughSwitchClause": "off",
85118
"noAssignInExpressions": "off"
86119
},
87-
"nursery": {
88-
"noRestrictedImports": {
89-
"level": "error",
90-
"options": {
91-
"paths": {
92-
"lodash": "Import <method> from 'lodash/<method>' instead."
93-
}
94-
}
95-
}
96-
}
120+
"nursery": {}
97121
}
98122
},
99123
"formatter": {
100124
"enabled": true,
101125
"indentStyle": "space",
102126
"lineWidth": 100,
103-
"ignore": [
104-
"libs/keyboard.ts",
105-
"libs/stl_exporter.ts",
106-
"libs/DRACOLoader.ts",
107-
"libs/DRACOWorker.worker.js",
108-
"libs/BufferGeometryUtils.ts",
109-
"libs/parse_stl_buffer.ts",
110-
"libs/trackball_controls.ts",
111-
"*.d.ts",
112-
"**/__snapshots__/**"
127+
"includes": [
128+
113129
]
114130
},
131+
115132
"overrides": [
116133
{
117-
"include": [
134+
"includes": [
118135
"**/package.json"
119136
],
120137
"formatter": {

frontend/javascripts/admin/account/account_security_view.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import { useState } from "react";
88
import { useNavigate } from "react-router-dom";
99
import { logoutUserAction } from "viewer/model/actions/user_actions";
1010
import { SettingsTitle } from "./helpers/settings_title";
11+
1112
const FormItem = Form.Item;
1213
const { Password } = Input;
14+
1315
import { useDispatch } from "react-redux";
1416
import PasskeysView from "../auth/passkeys_view";
1517
import { SettingsCard, type SettingsCardProps } from "./helpers/settings_card";

frontend/javascripts/admin/api/jobs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { location } from "libs/window";
33
import camelCase from "lodash-es/camelCase";
44
import mapKeys from "lodash-es/mapKeys";
55
import type {
6-
APIAnnotationType,
7-
APIJob,
86
AdditionalCoordinate,
97
AiModel,
8+
APIAnnotationType,
9+
APIJob,
1010
RenderAnimationOptions,
1111
} from "types/api_types";
1212
import type { UnitLong, Vector3, Vector6 } from "viewer/constants";

frontend/javascripts/admin/auth/authentication_modal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { ComponentType } from "react";
88
import React, { useState } from "react";
99
import LoginForm from "./login_form";
1010
import RegistrationFormGeneric from "./registration_form_generic";
11+
1112
type Props = {
1213
onLoggedIn: (userJustRegistered: boolean) => unknown;
1314
onCancel: () => void;

frontend/javascripts/admin/auth/change_email_view.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { logoutUserEverywhere, updateUser } from "admin/rest_api";
33
import { Alert, Button, Form, Input, Space } from "antd";
44
import { useWkSelector } from "libs/react_hooks";
55
import Toast from "libs/toast";
6-
import { logoutUserAction } from "viewer/model/actions/user_actions";
7-
86
import { useDispatch } from "react-redux";
97
import { useNavigate } from "react-router-dom";
8+
import { logoutUserAction } from "viewer/model/actions/user_actions";
109
import { handleResendVerificationEmail } from "./verify_email_view";
1110

1211
const FormItem = Form.Item;

frontend/javascripts/admin/auth/passkeys_view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { DeleteOutlined } from "@ant-design/icons";
22
import {
3-
type WebAuthnKeyDescriptor,
43
doWebAuthnRegistration,
54
listWebAuthnKeys,
65
removeWebAuthnKey,
6+
type WebAuthnKeyDescriptor,
77
} from "admin/api/webauthn";
88
import { Button, Input, Modal, Table } from "antd";
99
import Toast from "libs/toast";

frontend/javascripts/admin/auth/start_reset_password_view.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Request from "libs/request";
44
import Toast from "libs/toast";
55
import messages from "messages";
66
import { Link, useNavigate } from "react-router-dom";
7+
78
const FormItem = Form.Item;
89

910
function StartResetPasswordView() {

frontend/javascripts/admin/dataset/composition_wizard/02_upload_files.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import type { Vector3 } from "viewer/constants";
1111
import { parseNml } from "viewer/model/helpers/nml_helpers";
1212
import {
1313
type FileList,
14+
tryToFetchDatasetsByNameOrId,
1415
type WizardComponentProps,
1516
type WizardContext,
16-
tryToFetchDatasetsByNameOrId,
1717
} from "./common";
1818

1919
const EXPECTED_VALUE_COUNT_PER_CSV_LINE = 8;
@@ -136,8 +136,12 @@ async function parseBigWarpFile(fileList: FileList): Promise<Partial<WizardConte
136136
const [_pointName, enabled, x1, y1, z1, x2, y2, z2] = fields;
137137

138138
if (enabled) {
139-
const source = [x1, y1, z1].map((el) => Number.parseInt(el.replaceAll('"', ""))) as Vector3;
140-
const target = [x2, y2, z2].map((el) => Number.parseInt(el.replaceAll('"', ""))) as Vector3;
139+
const source = [x1, y1, z1].map((el) =>
140+
Number.parseInt(el.replaceAll('"', ""), 10),
141+
) as Vector3;
142+
const target = [x2, y2, z2].map((el) =>
143+
Number.parseInt(el.replaceAll('"', ""), 10),
144+
) as Vector3;
141145
sourcePoints.push(source);
142146
targetPoints.push(target);
143147
}
@@ -158,8 +162,12 @@ async function parseNmlFiles(fileList: FileList): Promise<Partial<WizardContext>
158162
throw new SoftError("Expected exactly two NML files.");
159163
}
160164

161-
const nmlString1 = await readFileAsText(fileList[0]?.originFileObj!);
162-
const nmlString2 = await readFileAsText(fileList[1]?.originFileObj!);
165+
if (fileList[0]?.originFileObj == null || fileList[1]?.originFileObj == null) {
166+
throw new SoftError("Expected exactly two NML files.");
167+
}
168+
169+
const nmlString1 = await readFileAsText(fileList[0]?.originFileObj);
170+
const nmlString2 = await readFileAsText(fileList[1]?.originFileObj);
163171

164172
if (nmlString1 === "" || nmlString2 === "") {
165173
throw new SoftError("NML files should not be empty.");

frontend/javascripts/admin/dataset/composition_wizard/03_select_datasets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import DatasetSelectionComponent, {
55
} from "dashboard/dataset/dataset_selection_component";
66
import { useEffectOnlyOnce } from "libs/react_hooks";
77
import { useState } from "react";
8-
import { type WizardComponentProps, tryToFetchDatasetsByNameOrId } from "./common";
8+
import { tryToFetchDatasetsByNameOrId, type WizardComponentProps } from "./common";
99

1010
export default function SelectDatasets({ wizardContext, setWizardContext }: WizardComponentProps) {
1111
const [datasetValues, setDatasetValues] = useState<DatasetSelectionValue[]>([]);

frontend/javascripts/admin/dataset/composition_wizard/04_configure_new_dataset.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import FolderSelection from "dashboard/folders/folder_selection";
2222
import ErrorHandling from "libs/error_handling";
2323
import { estimateAffineMatrix4x4 } from "libs/estimate_affine";
2424
import { formatNumber } from "libs/format_utils";
25-
import { useEffectOnlyOnce } from "libs/react_hooks";
26-
import { useWkSelector } from "libs/react_hooks";
25+
import { useEffectOnlyOnce, useWkSelector } from "libs/react_hooks";
2726
import Toast from "libs/toast";
2827
import { isUserAdminOrDatasetManager } from "libs/utils";
2928
import uniqBy from "lodash-es/uniqBy";

0 commit comments

Comments
 (0)