Skip to content

Commit 07aeb97

Browse files
committed
fix: sonar cloud code smells
1 parent a0ea94c commit 07aeb97

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/components/Form/FieldUpload/FieldUpload.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const mockFile: FieldUploadValue = {
1717
lastModifiedDate: new Date(mockFileRaw.lastModified),
1818
size: mockFileRaw.size.toString(),
1919
type: mockFileRaw.type,
20-
name: mockFileRaw.name,
20+
name: mockFileRaw.name ?? '',
2121
};
2222

2323
test('update value', async () => {
@@ -75,7 +75,7 @@ test('default value', async () => {
7575
);
7676

7777
// Here we can use '!' on mockFile.name to prevent TS error because we are sure it is defined
78-
const input = screen.getByLabelText<HTMLInputElement>(mockFile.name!);
78+
const input = screen.getByLabelText<HTMLInputElement>(mockFile.name ?? '');
7979
expect(input.files ? input.files[0] : []).toBe(undefined);
8080
await user.click(screen.getByRole('button', { name: 'Submit' }));
8181
expect(mockedSubmit).toHaveBeenCalledWith({ file: mockFile });

src/components/Form/FieldUpload/index.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { ChangeEvent, ReactNode } from 'react';
22

3-
import { Icon, Spinner, chakra } from '@chakra-ui/react';
4-
import { Input, InputProps } from '@chakra-ui/react';
3+
import {
4+
Icon,
5+
Input,
6+
type InputProps,
7+
Spinner,
8+
chakra,
9+
} from '@chakra-ui/react';
510
import { Controller, FieldPath, FieldValues } from 'react-hook-form';
611
import { FiPaperclip } from 'react-icons/fi';
712

src/features/account/service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { useMutation } from '@tanstack/react-query';
2-
import { useQuery } from '@tanstack/react-query';
1+
import { useMutation, useQuery } from '@tanstack/react-query';
32

43
import { trpc } from '@/lib/trpc/client';
54

0 commit comments

Comments
 (0)