Skip to content

Commit 110e0ce

Browse files
authored
Fix lint / compile issues and Form typings (#1813)
1 parent cc36497 commit 110e0ce

22 files changed

Lines changed: 1966 additions & 3269 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ jobs:
168168
[ -z "$VERSION" ] && VERSION="0.0.0"
169169
VERSION="${VERSION#v}"
170170
echo "Building version: $VERSION"
171-
cd gui
172171
pnpm i
172+
cd gui
173173
pnpm exec electron-builder --${{ matrix.platform }} \
174174
${{ matrix.platform == 'macos' && '--universal' || '' }} \
175175
--config.extraMetadata.version="$VERSION" \

gui/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
"electron": "^40.3.0",
7171
"electron-builder": "^26.7.0",
7272
"electron-vite": "^5.0.0",
73+
"@eslint/eslintrc": "^3.3.5",
74+
"@eslint/js": "^9.39.4",
7375
"eslint": "^9.39.1",
7476
"eslint-import-resolver-typescript": "^3.10.1",
7577
"eslint-plugin-import": "^2.32.0",

gui/src/components/MainLayout.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
't t t' var(--topbar-h)
1515
'n b s' var(--toolbar-h)
1616
'n c s' calc(100% - var(--topbar-h) - var(--toolbar-h))
17-
/ var(--navbar-w) calc(100% - var(--navbar-w) - var(--right-section-w)) var(--right-section-w);
17+
/ var(--navbar-w) calc(100% - var(--navbar-w) - var(--right-section-w))
18+
var(--right-section-w);
1819
}
1920

2021
@screen nsm {

gui/src/components/commons/Checkbox.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import classNames from 'classnames';
22
import { forwardRef, useMemo } from 'react';
3-
import { Control, Controller } from 'react-hook-form';
3+
import { Control, Controller, FieldPath, FieldValues } from 'react-hook-form';
44

55
export const CHECKBOX_CLASSES = classNames(
66
'bg-background-50 border-background-50 cursor-pointer rounded-md w-5 h-5 text-accent-background-30 focus:border-accent-background-40 focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent'
@@ -112,7 +112,7 @@ export const CheckboxInternal = forwardRef<
112112
);
113113
});
114114

115-
export function CheckBox({
115+
export function CheckBox<T extends FieldValues = FieldValues>({
116116
label,
117117
variant = 'checkbox',
118118
color = 'primary',
@@ -123,8 +123,8 @@ export function CheckBox({
123123
disabled,
124124
}: {
125125
label: string;
126-
control: Control<any>;
127-
name: string;
126+
control: Control<T>;
127+
name: FieldPath<T>;
128128
variant?: 'checkbox' | 'toggle';
129129
color?: 'primary' | 'secondary' | 'tertiary';
130130
outlined?: boolean;

gui/src/components/commons/Dropdown.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
import {
1111
Control,
1212
FieldError,
13+
FieldPath,
14+
FieldValues,
1315
useController,
1416
UseControllerProps,
1517
} from 'react-hook-form';
@@ -415,14 +417,15 @@ export function DropdownInside({
415417
);
416418
}
417419

418-
export function Dropdown({
420+
export function Dropdown<T extends FieldValues = FieldValues>({
419421
control,
420422
name,
421423
rules,
422424
...props
423425
}: DropdownProps & {
424-
control: Control<any>;
425-
rules?: UseControllerProps<any>['rules'];
426+
control: Control<T>;
427+
name: FieldPath<T>;
428+
rules?: UseControllerProps<T, FieldPath<T>>['rules'];
426429
}) {
427430
const {
428431
field: { value, onChange },

gui/src/components/commons/FileInput.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import {
77
useRef,
88
useState,
99
} from 'react';
10-
import { Control, Controller, UseControllerProps } from 'react-hook-form';
10+
import {
11+
Control,
12+
Controller,
13+
FieldPath,
14+
FieldValues,
15+
UseControllerProps,
16+
} from 'react-hook-form';
1117
import { FileIcon } from './icon/FileIcon';
1218
import { UploadFileIcon } from './icon/UploadFileIcon';
1319
import { Typography } from './Typography';
@@ -193,7 +199,7 @@ export const FileInputInside = forwardRef<
193199
);
194200
});
195201

196-
export const FileInput = ({
202+
export const FileInput = <T extends FieldValues = FieldValues>({
197203
control,
198204
name,
199205
label,
@@ -204,8 +210,9 @@ export const FileInput = ({
204210
capture,
205211
importedFileName,
206212
}: {
207-
rules: UseControllerProps<any>['rules'];
208-
control: Control<any>;
213+
rules: UseControllerProps<T, FieldPath<T>>['rules'];
214+
control: Control<T>;
215+
name: FieldPath<T>;
209216
accept: string;
210217
multiple?: boolean;
211218
capture?: boolean | 'user' | 'environment';
@@ -214,7 +221,7 @@ export const FileInput = ({
214221
**/
215222
label?: string;
216223
importedFileName: string | null;
217-
} & InputProps &
224+
} & Omit<InputProps, 'name'> &
218225
Partial<HTMLInputElement>) => {
219226
return (
220227
<Controller

gui/src/components/commons/Input.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
Control,
55
Controller,
66
FieldError,
7+
FieldPath,
8+
FieldValues,
79
UseControllerProps,
810
} from 'react-hook-form';
911
import { EyeIcon } from './icon/EyeIcon';
@@ -117,7 +119,7 @@ export const InputInside = forwardRef<
117119
);
118120
});
119121

120-
export const Input = ({
122+
export const Input = <T extends FieldValues = FieldValues>({
121123
type = 'text',
122124
control,
123125
name,
@@ -128,10 +130,11 @@ export const Input = ({
128130
variant = 'primary',
129131
rules,
130132
}: {
131-
rules?: UseControllerProps<any>['rules'];
132-
control: Control<any>;
133+
rules?: UseControllerProps<T, FieldPath<T>>['rules'];
134+
control: Control<T>;
135+
name: FieldPath<T>;
133136
autocomplete?: boolean | string;
134-
} & InputProps &
137+
} & Omit<InputProps, 'name'> &
135138
Partial<React.HTMLProps<HTMLInputElement>>) => {
136139
return (
137140
<Controller

gui/src/components/commons/NumberSelector.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Control, Controller } from 'react-hook-form';
1+
import { Control, Controller, FieldPath, FieldValues } from 'react-hook-form';
22
import { Button } from './Button';
33
import { Typography } from './Typography';
44
import { useCallback, useMemo } from 'react';
55
import { useLocaleConfig } from '@/i18n/config';
66

7-
export function NumberSelector({
7+
export function NumberSelector<T extends FieldValues = FieldValues>({
88
label,
99
valueLabelFormat,
1010
control,
@@ -18,8 +18,8 @@ export function NumberSelector({
1818
}: {
1919
label?: string;
2020
valueLabelFormat?: (value: number) => string;
21-
control: Control<any>;
22-
name: string;
21+
control: Control<T>;
22+
name: FieldPath<T>;
2323
min: number;
2424
max: number;
2525
step: number | ((value: number, add: boolean) => number);

gui/src/components/commons/Radio.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import classNames from 'classnames';
2-
import { Control, Controller } from 'react-hook-form';
2+
import { Control, Controller, FieldPath, FieldValues } from 'react-hook-form';
33
import { Typography } from './Typography';
44
import { ReactNode } from 'react';
55

6-
export function Radio({
6+
export function Radio<T extends FieldValues = FieldValues>({
77
control,
88
name,
99
label,
@@ -14,8 +14,8 @@ export function Radio({
1414
disabled,
1515
...props
1616
}: {
17-
control: Control<any>;
18-
name: string;
17+
control: Control<T>;
18+
name: FieldPath<T>;
1919
label?: string;
2020
value: string;
2121
description?: string | null;

gui/src/components/commons/Range.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import classNames from 'classnames';
2-
import { Control, Controller } from 'react-hook-form';
2+
import { Control, Controller, FieldPath, FieldValues } from 'react-hook-form';
33

4-
export function Range({
4+
export function Range<T extends FieldValues = FieldValues>({
55
control,
66
name,
77
values,
@@ -11,8 +11,8 @@ export function Range({
1111
// input props
1212
...props
1313
}: {
14-
control: Control<any>;
15-
name: string;
14+
control: Control<T>;
15+
name: FieldPath<T>;
1616
max: number;
1717
min: number;
1818
step: number;

0 commit comments

Comments
 (0)