Skip to content

Commit 88ae753

Browse files
fix some linting issues
1 parent a08c189 commit 88ae753

File tree

9 files changed

+31
-39
lines changed

9 files changed

+31
-39
lines changed

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"build": "tsc --noEmit && vite build",
88
"serve": "vite preview",
99
"build-env-check": "node ./react-build-env-checker.js && vite build",
10+
"lint": "eslint \"src/**/*.+(ts|tsx|js)\"",
1011
"test": "vitest",
1112
"test-all": "vitest --run",
1213
"test-all:coverage": "vitest --run --coverage src",

app/src/components/blocks/_delete/deleteResultStage/DeleteResultStage.test.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@ import { DOWNLOAD_STAGE } from '../../../../types/generic/downloadStage';
1111
import { runAxeTest } from '../../../../helpers/test/axeTestHelper';
1212
import { afterEach, beforeEach, describe, expect, it, vi, Mock } from 'vitest';
1313
import useConfig from '../../../../helpers/hooks/useConfig';
14-
import { getDocumentTypeLabel } from '../../../../helpers/utils/documentType';
1514

1615
const mockNavigate = vi.fn();
1716

1817
vi.mock('../../../../helpers/hooks/useRole');
1918
vi.mock('../../../../helpers/hooks/usePatient');
2019
vi.mock('../../../../helpers/hooks/useConfig');
2120
vi.mock('react-router-dom', () => ({
22-
Link: (props: LinkProps) => <a {...props} role="link" />,
23-
useNavigate: () => mockNavigate,
21+
Link: (props: LinkProps): React.JSX.Element => <a {...props} role="link" />,
22+
useNavigate: (): Mock => mockNavigate,
2423
}));
2524

2625
const mockedUseRole = useRole as Mock;
2726
const mockedUsePatient = usePatient as Mock;
2827
const mockedUseConfig = useConfig as Mock;
2928

3029
const mockPatientDetails = buildPatientDetails();
31-
const mockLgSearchResult = buildLgSearchResult();
3230
const mockSetDownloadStage = vi.fn();
3331

3432
describe('DeleteResultStage', () => {
@@ -74,7 +72,6 @@ describe('DeleteResultStage', () => {
7472
);
7573
it('renders the page with ARF patient details, when user role is PCSE', async () => {
7674
const patientName = `${mockPatientDetails.givenName} ${mockPatientDetails.familyName}`;
77-
const numberOfFiles = 1;
7875

7976
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);
8077
render(<DeleteResultStage setDownloadStage={mockSetDownloadStage} />);
@@ -95,7 +92,6 @@ describe('DeleteResultStage', () => {
9592
it.each([REPOSITORY_ROLE.GP_ADMIN, REPOSITORY_ROLE.GP_CLINICAL])(
9693
"renders the return to Lloyd George Record button, when user role is '%s'",
9794
async (role) => {
98-
const numberOfFiles = mockLgSearchResult.numberOfFiles;
9995
mockedUseRole.mockReturnValue(role);
10096

10197
render(<DeleteResultStage setDownloadStage={mockSetDownloadStage} />);
@@ -115,7 +111,6 @@ describe('DeleteResultStage', () => {
115111
);
116112

117113
it('does not render the return to Lloyd George Record button, when user role is PCSE', async () => {
118-
const numberOfFiles = mockLgSearchResult.numberOfFiles;
119114
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);
120115

121116
render(<DeleteResultStage setDownloadStage={mockSetDownloadStage} />);
@@ -134,7 +129,6 @@ describe('DeleteResultStage', () => {
134129
});
135130

136131
it('renders the Start Again button, when user role is PCSE', async () => {
137-
const numberOfFiles = 7;
138132
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);
139133

140134
render(<DeleteResultStage setDownloadStage={mockSetDownloadStage} />);
@@ -155,7 +149,6 @@ describe('DeleteResultStage', () => {
155149
it.each([REPOSITORY_ROLE.GP_ADMIN, REPOSITORY_ROLE.GP_CLINICAL])(
156150
"does not render the Start Again button, when user role is '%s'",
157151
async (role) => {
158-
const numberOfFiles = 7;
159152
mockedUseRole.mockReturnValue(role);
160153

161154
render(<DeleteResultStage setDownloadStage={mockSetDownloadStage} />);
@@ -214,7 +207,6 @@ describe('DeleteResultStage', () => {
214207
);
215208

216209
it('navigates to Home page when link is clicked when user role is PCSE', async () => {
217-
const numberOfFiles = 7;
218210
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);
219211

220212
render(<DeleteResultStage setDownloadStage={mockSetDownloadStage} />);

app/src/components/blocks/_delete/deleteResultStage/DeleteResultStage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ const DeleteResultStage = ({ docType, setDownloadStage }: Props): React.JSX.Elem
2525
if (setDownloadStage) {
2626
setDownloadStage(DOWNLOAD_STAGE.REFRESH);
2727
}
28-
navigate(config.featureFlags.uploadDocumentIteration3Enabled
29-
? routes.PATIENT_DOCUMENTS
30-
: routes.LLOYD_GEORGE
28+
navigate(
29+
config.featureFlags.uploadDocumentIteration3Enabled
30+
? routes.PATIENT_DOCUMENTS
31+
: routes.LLOYD_GEORGE,
3132
);
3233
};
3334

app/src/components/blocks/_delete/deleteSubmitStage/DeleteSubmitStage.test.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ vi.mock('react-router-dom', async () => {
2929
const actual = await vi.importActual('react-router-dom');
3030
return {
3131
...actual,
32-
useNavigate: () => mockedUseNavigate,
32+
useNavigate: (): Mock => mockedUseNavigate,
3333
};
3434
});
35-
Date.now = () => new Date('2020-01-01T00:00:00.000Z').getTime();
35+
Date.now = (): number => new Date('2020-01-01T00:00:00.000Z').getTime();
3636

3737
let history: MemoryHistory = createMemoryHistory({
3838
initialEntries: ['/'],
@@ -44,7 +44,6 @@ const mockedAxios = axios as Mocked<typeof axios>;
4444
const mockedUsePatient = usePatient as Mock;
4545
const mockResetDocState = vi.fn();
4646
const mockPatientDetails = buildPatientDetails();
47-
const mockLgSearchResult = buildLgSearchResult();
4847
const mockuseConfig = useConfig as Mock;
4948

5049
const mockSetStage = vi.fn();
@@ -367,13 +366,13 @@ describe('DeleteSubmitStage', () => {
367366
});
368367
});
369368

370-
const renderComponent = (docType: DOCUMENT_TYPE, history: MemoryHistory) => {
369+
const renderComponent = (docType: DOCUMENT_TYPE, history: MemoryHistory): void => {
371370
const props: Omit<Props, 'setStage' | 'setDownloadStage'> = {
372371
docType,
373372
resetDocState: mockResetDocState,
374373
};
375374

376-
return render(
375+
render(
377376
<ReactRouter.Router navigator={history} location={history.location}>
378377
<DeleteSubmitStage {...props} />,
379378
</ReactRouter.Router>,

app/src/components/blocks/_delete/deleteSubmitStage/DeleteSubmitStage.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,7 @@ const DeleteSubmitStage = ({
252252
<Route
253253
path={getLastURLPath(routeChildren.DOCUMENT_DELETE_COMPLETE)}
254254
element={
255-
<DeleteResultStage
256-
docType={docType}
257-
setDownloadStage={setDownloadStage}
258-
/>
255+
<DeleteResultStage docType={docType} setDownloadStage={setDownloadStage} />
259256
}
260257
/>
261258
</Routes>

app/src/components/blocks/_delete/removeRecordStage/RemoveRecordStage.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { DOCUMENT_TYPE, getDocumentTypeLabel } from '../../../../helpers/utils/d
1212
import useConfig from '../../../../helpers/hooks/useConfig';
1313

1414
vi.mock('axios');
15-
Date.now = () => new Date('2020-01-01T00:00:00.000Z').getTime();
15+
Date.now = (): number => new Date('2020-01-01T00:00:00.000Z').getTime();
1616
vi.mock('react-router-dom', async () => ({
1717
...(await vi.importActual('react-router-dom')),
18-
useNavigate: () => mockUseNavigate,
18+
useNavigate: (): Mock => mockUseNavigate,
1919
}));
2020
vi.mock('../../../../helpers/hooks/useBaseAPIHeaders');
2121
vi.mock('../../../../helpers/hooks/useBaseAPIUrl');
@@ -160,8 +160,8 @@ describe('RemoveRecordStage', () => {
160160
});
161161
});
162162

163-
const renderComponent = (history: MemoryHistory, recordType: DOCUMENT_TYPE) => {
164-
return render(
163+
const renderComponent = (history: MemoryHistory, recordType: DOCUMENT_TYPE): void => {
164+
render(
165165
<ReactRouter.Router navigator={history} location={history.location}>
166166
<RemoveRecordStage
167167
docType={recordType}

app/src/components/blocks/_delete/removeRecordStage/RemoveRecordStage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const RemoveRecordStage = ({
110110
return config.featureFlags.uploadDocumentIteration3Enabled
111111
? routeChildren.DOCUMENT_DELETE_CONFIRMATION
112112
: routeChildren.LLOYD_GEORGE_DELETE_CONFIRMATION;
113-
}
113+
};
114114

115115
const PageIndexView = (): React.JSX.Element => (
116116
<>
@@ -208,7 +208,9 @@ const RemoveRecordStage = ({
208208
></Route>
209209
<Route
210210
path={getLastURLPath(routeChildren.LLOYD_GEORGE_DELETE_COMPLETE)}
211-
element={<DeleteResultStage docType={docType} setDownloadStage={setDownloadStage} />}
211+
element={
212+
<DeleteResultStage docType={docType} setDownloadStage={setDownloadStage} />
213+
}
212214
></Route>
213215
</Routes>
214216
<Outlet></Outlet>

app/src/pages/documentSearchResultsPage/DocumentSearchResultsPage.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen, waitFor } from '@testing-library/react';
2-
import { act } from 'react';
2+
import React, { act } from 'react';
33
import DocumentSearchResultsPage from './DocumentSearchResultsPage';
44
import userEvent from '@testing-library/user-event';
55
import {
@@ -20,12 +20,12 @@ import { REPOSITORY_ROLE } from '../../types/generic/authRole';
2020
const mockedUseNavigate = vi.fn();
2121
vi.mock('react-router-dom', async () => ({
2222
...(await vi.importActual('react-router-dom')),
23-
useNavigate: () => mockedUseNavigate,
24-
Link: (props: ReactRouter.LinkProps) => <a {...props} role="link" />,
23+
useNavigate: (): Mock => mockedUseNavigate,
24+
Link: (props: ReactRouter.LinkProps): React.JSX.Element => <a {...props} role="link" />,
2525
}));
2626

2727
vi.mock('axios');
28-
Date.now = () => new Date('2020-01-01T00:00:00.000Z').getTime();
28+
Date.now = (): number => new Date('2020-01-01T00:00:00.000Z').getTime();
2929
vi.mock('../../helpers/hooks/useBaseAPIHeaders');
3030
vi.mock('../../helpers/hooks/usePatient');
3131
vi.mock('../../helpers/hooks/useConfig');
@@ -265,12 +265,12 @@ describe('<DocumentSearchResultsPage />', () => {
265265
});
266266
});
267267

268-
const renderPage = (history: History, role?: REPOSITORY_ROLE) => {
268+
const renderPage = (history: History, role?: REPOSITORY_ROLE): void => {
269269
const auth: Session = {
270270
auth: buildUserAuth({ role: role ?? REPOSITORY_ROLE.GP_ADMIN }),
271271
isLoggedIn: true,
272272
};
273-
return render(
273+
render(
274274
<SessionProvider sessionOverride={auth}>
275275
<ReactRouter.Router navigator={history} location={history.location}>
276276
<DocumentSearchResultsPage />

app/src/pages/documentSearchResultsPage/DocumentSearchResultsPage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const DocumentSearchResultsPage = (): React.JSX.Element => {
105105
}
106106
}, [nhsNumber, navigate, baseUrl, baseHeaders, config]);
107107

108-
const onViewDocument = (documentItem: SearchResult) => {
108+
const onViewDocument = (documentItem: SearchResult): void => {
109109
activeSearchResult.current = documentItem;
110110
setDocumentReference({
111111
isPdf: documentItem.contentType === 'application/pdf',
@@ -116,7 +116,7 @@ const DocumentSearchResultsPage = (): React.JSX.Element => {
116116
loadDocument(documentItem.id);
117117
};
118118

119-
const loadDocument = async (documentId: string) => {
119+
const loadDocument = async (documentId: string): Promise<void> => {
120120
try {
121121
const documentResponse = await getDocument({
122122
nhsNumber: patientDetails!.nhsNumber,
@@ -149,7 +149,7 @@ const DocumentSearchResultsPage = (): React.JSX.Element => {
149149
} as DocumentReference);
150150
};
151151

152-
const getObjectUrl = async (cloudFrontUrl: string) => {
152+
const getObjectUrl = async (cloudFrontUrl: string): Promise<string> => {
153153
const { data } = await axios.get(cloudFrontUrl, {
154154
responseType: 'blob',
155155
});
@@ -234,8 +234,8 @@ const DocumentSearchResultsPageIndex = ({
234234

235235
const SearchResults = (): React.JSX.Element => {
236236
if (
237-
submissionState == SUBMISSION_STATE.INITIAL ||
238-
submissionState == SUBMISSION_STATE.PENDING
237+
submissionState === SUBMISSION_STATE.INITIAL ||
238+
submissionState === SUBMISSION_STATE.PENDING
239239
) {
240240
return <ProgressBar status="Loading..." className="loading-bar" />;
241241
}

0 commit comments

Comments
 (0)