Skip to content

Commit 3070e75

Browse files
lint: fix lint errors
1 parent 1670c90 commit 3070e75

File tree

189 files changed

+1684
-1276
lines changed

Some content is hidden

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

189 files changed

+1684
-1276
lines changed

common/router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import React from 'react';
7-
import { useHistory } from "react-router-dom";
7+
import { useHistory } from 'react-router-dom';
88
import { Monitoring } from '../public/components/monitoring';
99
import { ModelRegister } from '../public/dashboard-assistant/components/model-register';
1010
import { routerPaths } from './router_paths';

public/components/app.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type { DataSourcePluginSetup } from '../../../../src/plugins/data_source/
2323

2424
import { GlobalBreadcrumbs } from './global_breadcrumbs';
2525
import { DataSourceTopNavMenu } from './data_source_top_nav_menu';
26-
import Providers from './providers';
26+
import { Providers } from './providers';
2727

2828
interface MlCommonsPluginAppDeps {
2929
basename: string;
@@ -61,14 +61,12 @@ export const MlCommonsPluginApp = ({
6161
application,
6262
}: MlCommonsPluginAppDeps) => {
6363
const dataSourceEnabled = !!dataSource;
64-
const useNewPageHeader = useObservable(
65-
uiSettingsClient.get$('home:useNewHomePage'),
66-
);
64+
const useNewPageHeader = useObservable(uiSettingsClient.get$('home:useNewHomePage'));
6765

6866
return (
6967
<Providers initialValue={{ dataSourceEnabled }}>
7068
<EuiPage>
71-
<EuiPageBody component='main'>
69+
<EuiPageBody component="main">
7270
<Switch>
7371
{ROUTES.map(({ path, Component, exact }) => (
7472
<Route
@@ -93,9 +91,7 @@ export const MlCommonsPluginApp = ({
9391
</EuiPageBody>
9492
</EuiPage>
9593
{/* Breadcrumbs will contains dynamic content in new page header, should be provided by each page self*/}
96-
{!useNewPageHeader && (
97-
<GlobalBreadcrumbs chrome={chrome} basename={basename} />
98-
)}
94+
{!useNewPageHeader && <GlobalBreadcrumbs chrome={chrome} basename={basename} />}
9995
{dataSourceEnabled && (
10096
<DataSourceTopNavMenu
10197
notifications={notifications}

public/components/delete_model_modal/__tests__/delete_model_modal.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ describe('<DeleteModelModal />', () => {
4444
}}
4545
onClose={onClose}
4646
onDeleted={onDeleted}
47-
/>,
47+
/>
4848
);
4949

5050
expect(
5151
await screen.findByRole('heading', {
5252
name: 'Delete model: model 1 name',
53-
}),
53+
})
5454
).toBeInTheDocument();
5555

5656
const confirmButton = screen.getByRole('button', { name: 'Delete model' });

public/components/delete_model_modal/index.tsx

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ export interface DeleteModelModalProps {
2828
onDeleted?: () => void | Promise<void>;
2929
}
3030

31-
export const DeleteModelModal = ({
32-
model,
33-
onClose,
34-
onDeleted,
35-
}: DeleteModelModalProps) => {
31+
export const DeleteModelModal = ({ model, onClose, onDeleted }: DeleteModelModalProps) => {
3632
const { deleteModel, isDeleting } = useDeleteModel();
3733
const [confirmationText, setConfirmationText] = useState('');
3834

@@ -42,53 +38,47 @@ export const DeleteModelModal = ({
4238
if (onDeleted) await onDeleted();
4339
}, [deleteModel, model.id, onClose, onDeleted]);
4440

45-
const updateConfirmationText = (
46-
e: React.SyntheticEvent<HTMLInputElement>,
47-
) => {
41+
const updateConfirmationText = (e: React.SyntheticEvent<HTMLInputElement>) => {
4842
const value = (e.target as HTMLInputElement).value;
4943
setConfirmationText(value);
5044
};
5145

5246
return (
5347
<EuiOverlayMask>
54-
<EuiModal onClose={onClose} initialFocus='[name=modelName]'>
48+
<EuiModal onClose={onClose} initialFocus="[name=modelName]">
5549
<EuiModalHeader>
5650
<EuiModalHeaderTitle>
5751
<h1>Delete model: {model.name}</h1>
5852
</EuiModalHeaderTitle>
5953
</EuiModalHeader>
6054
<EuiModalBody>
61-
<EuiText size='s'>
62-
This action permanently deletes the model and related entities. To
63-
confirm, type the model name exactly.
55+
<EuiText size="s">
56+
This action permanently deletes the model and related entities. To confirm, type the
57+
model name exactly.
6458
</EuiText>
65-
<EuiSpacer size='m' />
66-
<EuiForm component='form'>
59+
<EuiSpacer size="m" />
60+
<EuiForm component="form">
6761
<EuiFormRow label={`Type \"${model.name}\" to confirm`} fullWidth>
6862
<EuiFieldText
6963
fullWidth
70-
name='modelName'
64+
name="modelName"
7165
value={confirmationText}
7266
onChange={updateConfirmationText}
7367
/>
7468
</EuiFormRow>
7569
</EuiForm>
7670
</EuiModalBody>
7771
<EuiModalFooter>
78-
<EuiButton
79-
onClick={onClose}
80-
color='text'
81-
data-test-subj='cancelDeleteModelButton'
82-
>
72+
<EuiButton onClick={onClose} color="text" data-test-subj="cancelDeleteModelButton">
8373
Cancel
8474
</EuiButton>
8575
<EuiButton
8676
fill
87-
color='danger'
77+
color="danger"
8878
onClick={confirmDelete}
8979
isLoading={isDeleting}
9080
isDisabled={confirmationText.trim() !== model.name}
91-
data-test-subj='confirmDeleteModelButton'
81+
data-test-subj="confirmDeleteModelButton"
9282
>
9383
Delete model
9484
</EuiButton>

public/components/monitoring/__tests__/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ describe('<Monitoring />', () => {
383383

384384
// click on first item: responding: 1, not responding: 2, planning: 3
385385
const headers = screen.getAllByRole('columnheader');
386-
const actionsIndex = headers.findIndex(h => within(h).queryByText('Actions'));
386+
const actionsIndex = headers.findIndex((h) => within(h).queryByText('Actions'));
387387
const table = headers[0].closest('table') as HTMLTableElement;
388388
const firstRow = table.querySelectorAll('tbody tr')[0] as HTMLElement;
389389
const actionsCell = firstRow.querySelectorAll('td')[actionsIndex] as HTMLElement;
@@ -418,7 +418,7 @@ describe('<Monitoring />', () => {
418418

419419
// click on first item: responding: 1, not responding: 2, planning: 3
420420
const headers = screen.getAllByRole('columnheader');
421-
const actionsIndex = headers.findIndex(h => within(h).queryByText('Actions'));
421+
const actionsIndex = headers.findIndex((h) => within(h).queryByText('Actions'));
422422
const table = headers[0].closest('table') as HTMLTableElement;
423423
const firstRow = table.querySelectorAll('tbody tr')[0] as HTMLElement;
424424
const actionsCell = firstRow.querySelectorAll('td')[actionsIndex] as HTMLElement;

public/components/monitoring/__tests__/model_delete_button_enabled.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import React from 'react';
77
import userEvent from '@testing-library/user-event';
88
import { render, screen } from '../../../../test/test_utils';
9-
import {
10-
ModelDeploymentTable,
11-
ModelDeploymentTableProps,
12-
} from '../model_deployment_table';
9+
import { ModelDeploymentTable, ModelDeploymentTableProps } from '../model_deployment_table';
1310

1411
describe('Model delete button', () => {
1512
it('is enabled even when model is in use and invokes onDeleteModel', async () => {
@@ -33,7 +30,7 @@ describe('Model delete button', () => {
3330
sort={{ field: 'name', direction: 'asc' }}
3431
onChange={jest.fn()}
3532
onDeleteModel={onDeleteModel}
36-
/>,
33+
/>
3734
);
3835

3936
// Delete action may be inline or under the "All actions" popover depending on layout.
@@ -42,13 +39,16 @@ describe('Model delete button', () => {
4239
const allActionsBtn = screen.getByRole('button', { name: /all actions/i });
4340
await user.click(allActionsBtn);
4441
// In the popover, actions are often rendered as menu items, but may also be buttons.
45-
deleteAction = screen.queryByRole('menuitem', { name: /delete model/i })
46-
|| screen.queryByRole('button', { name: /delete model/i });
42+
deleteAction =
43+
screen.queryByRole('menuitem', { name: /delete model/i }) ||
44+
screen.queryByRole('button', { name: /delete model/i });
4745
if (!deleteAction) {
4846
// Wait briefly in case the popover renders asynchronously
49-
deleteAction = await screen.findByRole('menuitem', { name: /delete model/i }).catch(async () => {
50-
return await screen.findByRole('button', { name: /delete model/i });
51-
});
47+
deleteAction = await screen
48+
.findByRole('menuitem', { name: /delete model/i })
49+
.catch(async () => {
50+
return await screen.findByRole('button', { name: /delete model/i });
51+
});
5252
}
5353
}
5454

public/components/monitoring/__tests__/model_deployment_table.test.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,11 @@ describe('<DeployedModelTable />', () => {
207207
screen.queryByRole('menuitem', { name: /view status details/i }) ||
208208
screen.queryByRole('button', { name: /view status details/i });
209209
if (!viewAction) {
210-
viewAction = await screen.findByRole('menuitem', {
211-
name: /view status details/i,
212-
}).catch(async () => await screen.findByRole('button', { name: /view status details/i }));
210+
viewAction = await screen
211+
.findByRole('menuitem', {
212+
name: /view status details/i,
213+
})
214+
.catch(async () => await screen.findByRole('button', { name: /view status details/i }));
213215
}
214216
}
215217
await userEvent.click(viewAction!);
@@ -228,9 +230,11 @@ describe('<DeployedModelTable />', () => {
228230
screen.queryByRole('menuitem', { name: /view status details/i }) ||
229231
screen.queryByRole('button', { name: /view status details/i });
230232
if (!viewAction) {
231-
viewAction = await screen.findByRole('menuitem', {
232-
name: /view status details/i,
233-
}).catch(async () => await screen.findByRole('button', { name: /view status details/i }));
233+
viewAction = await screen
234+
.findByRole('menuitem', {
235+
name: /view status details/i,
236+
})
237+
.catch(async () => await screen.findByRole('button', { name: /view status details/i }));
234238
}
235239
}
236240
await userEvent.click(viewAction!);
@@ -249,9 +253,11 @@ describe('<DeployedModelTable />', () => {
249253
screen.queryByRole('menuitem', { name: /view status details/i }) ||
250254
screen.queryByRole('button', { name: /view status details/i });
251255
if (!viewAction) {
252-
viewAction = await screen.findByRole('menuitem', {
253-
name: /view status details/i,
254-
}).catch(async () => await screen.findByRole('button', { name: /view status details/i }));
256+
viewAction = await screen
257+
.findByRole('menuitem', {
258+
name: /view status details/i,
259+
})
260+
.catch(async () => await screen.findByRole('button', { name: /view status details/i }));
255261
}
256262
}
257263
await userEvent.click(viewAction!);

public/components/monitoring/__tests__/model_use_and_test_buttons.test.tsx

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import React from 'react';
77
import userEvent from '@testing-library/user-event';
88
import { render, screen, within } from '../../../../test/test_utils';
9-
import {
10-
ModelDeploymentTable,
11-
ModelDeploymentTableProps,
12-
} from '../model_deployment_table';
9+
import { ModelDeploymentTable, ModelDeploymentTableProps } from '../model_deployment_table';
1310

1411
describe('Model Use and Test actions', () => {
1512
const baseItem = {
@@ -43,26 +40,30 @@ describe('Model Use and Test actions', () => {
4340
onChange={jest.fn()}
4441
onUseModel={onUseModel}
4542
onTestModel={onTestModel}
46-
/>,
43+
/>
4744
);
4845

4946
// Find Actions column index
5047
const headers = screen.getAllByRole('columnheader');
51-
const actionsIndex = headers.findIndex(h => within(h).queryByText('Actions'));
52-
const rows = headers[0].closest('table')?.querySelectorAll('tbody tr') as NodeListOf<HTMLElement>;
48+
const actionsIndex = headers.findIndex((h) => within(h).queryByText('Actions'));
49+
const rows = headers[0].closest('table')?.querySelectorAll('tbody tr') as NodeListOf<
50+
HTMLElement
51+
>;
5352

5453
// Helper to get the Actions cell for a row
55-
const cellAt = (rowIdx: number) => rows[rowIdx].querySelectorAll('td')[actionsIndex] as HTMLElement;
54+
const cellAt = (rowIdx: number) =>
55+
rows[rowIdx].querySelectorAll('td')[actionsIndex] as HTMLElement;
5656

5757
// Row 0: Use should be enabled
58-
let use0 = within(cellAt(0)).queryByRole('button', { name: /use model/i });
58+
const use0 = within(cellAt(0)).queryByRole('button', { name: /use model/i });
5959
if (!use0) {
6060
const all0 = within(cellAt(0)).getByRole('button', { name: /all actions/i });
6161
await user.click(all0);
6262
const useInMenu = (await screen
6363
.findByRole('button', { name: /use model/i })
64-
.catch(async () => await screen.findByRole('menuitem', { name: /use model/i }))
65-
) as HTMLElement;
64+
.catch(
65+
async () => await screen.findByRole('menuitem', { name: /use model/i })
66+
)) as HTMLElement;
6667
expect(useInMenu).toBeEnabled();
6768
// close popover after checking
6869
await user.click(all0);
@@ -75,9 +76,11 @@ describe('Model Use and Test actions', () => {
7576
if (!use1) {
7677
const all1 = within(cellAt(1)).getByRole('button', { name: /all actions/i });
7778
await user.click(all1);
78-
use1 = (await screen.findByRole('menuitem', { name: /use model/i }).catch(async () =>
79-
await screen.findByRole('button', { name: /use model/i })
80-
)) as HTMLElement;
79+
use1 = (await screen
80+
.findByRole('menuitem', { name: /use model/i })
81+
.catch(
82+
async () => await screen.findByRole('button', { name: /use model/i })
83+
)) as HTMLElement;
8184
expect(use1).toBeDisabled();
8285
await user.click(all1);
8386
} else {
@@ -89,9 +92,11 @@ describe('Model Use and Test actions', () => {
8992
if (!use2) {
9093
const all2 = within(cellAt(2)).getByRole('button', { name: /all actions/i });
9194
await user.click(all2);
92-
use2 = (await screen.findByRole('menuitem', { name: /use model/i }).catch(async () =>
93-
await screen.findByRole('button', { name: /use model/i })
94-
)) as HTMLElement;
95+
use2 = (await screen
96+
.findByRole('menuitem', { name: /use model/i })
97+
.catch(
98+
async () => await screen.findByRole('button', { name: /use model/i })
99+
)) as HTMLElement;
95100
expect(use2).toBeDisabled();
96101
await user.click(all2);
97102
} else {
@@ -106,8 +111,9 @@ describe('Model Use and Test actions', () => {
106111
await user.click(all0);
107112
const menuUse0 = (await screen
108113
.findByRole('button', { name: /use model/i })
109-
.catch(async () => await screen.findByRole('menuitem', { name: /use model/i }))
110-
) as HTMLElement;
114+
.catch(
115+
async () => await screen.findByRole('menuitem', { name: /use model/i })
116+
)) as HTMLElement;
111117
await user.click(menuUse0);
112118
}
113119
expect(onUseModel).toHaveBeenCalledWith(items[0]);
@@ -117,9 +123,11 @@ describe('Model Use and Test actions', () => {
117123
if (!test2) {
118124
const all2 = within(cellAt(2)).getByRole('button', { name: /all actions/i });
119125
await user.click(all2);
120-
test2 = (await screen.findByRole('menuitem', { name: /test model/i }).catch(async () =>
121-
await screen.findByRole('button', { name: /test model/i })
122-
)) as HTMLElement;
126+
test2 = (await screen
127+
.findByRole('menuitem', { name: /test model/i })
128+
.catch(
129+
async () => await screen.findByRole('button', { name: /test model/i })
130+
)) as HTMLElement;
123131
}
124132
await user.click(test2!);
125133
expect(onTestModel).toHaveBeenCalledWith(items[2]);

0 commit comments

Comments
 (0)