Skip to content

Commit 19c7434

Browse files
authored
(chore) Migrate TypeScript ESLint to v8 (#585)
This PR upgrades TypeScript ESLint dependencies from v6 to v8 and fixes the resulting linting errors. It also upgrades core OpenMRS dependencies, improves test mocking patterns and fixes Carbon component usage to align with the v1.92.0 API. - Upgrade @typescript-eslint/eslint-plugin and parser from v6 to v8 - Update ESLint to v8.57.0 - Remove tsconfigRootDir from ESLint config (no longer needed) - Add @typescript-eslint/no-wrapper-object-types rule - Fix linting errors: remove deprecated DataTableSkeleton size prop - Fix NumberInput onChange handlers to match new type signatures - Update test mocking patterns to follow O3 conventions - Suppress single-spa warnings in test setup
1 parent 7c30ddb commit 19c7434

14 files changed

Lines changed: 295 additions & 370 deletions

.eslintrc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
],
2020
"parser": "@typescript-eslint/parser",
2121
"parserOptions": {
22-
"project": true,
23-
"tsconfigRootDir": "__dirname"
22+
"project": true
2423
},
2524
"plugins": ["@typescript-eslint", "import", "jest-dom", "react-hooks", "testing-library"],
2625
"root": true,
2726
"rules": {
28-
// The following rules need `noImplicitAny` to be set to `true` in our tsconfig. They are too restrictive for now, but should be reconsidered in future
2927
"@typescript-eslint/ban-types": "off",
3028
"@typescript-eslint/ban-ts-comment": "off",
3129
"@typescript-eslint/no-explicit-any": "off",
30+
"@typescript-eslint/no-wrapper-object-types": "off",
3231
"@typescript-eslint/no-floating-promises": "off",
3332
"@typescript-eslint/no-unsafe-argument": "off",
3433
"@typescript-eslint/no-unsafe-assignment": "off",
@@ -39,7 +38,6 @@
3938
"@typescript-eslint/unbound-method": "off",
4039
"@typescript-eslint/consistent-type-definitions": "off",
4140
"@typescript-eslint/consistent-type-exports": "error",
42-
// Use `import type` instead of `import` for type imports
4341
"@typescript-eslint/consistent-type-imports": [
4442
"error",
4543
{
@@ -52,7 +50,6 @@
5250
"error",
5351
{
5452
"paths": [
55-
// These two rules ensure that we're importing lodash and lodash-es correctly. Not doing so can bloat our bundle size significantly.
5653
{
5754
"name": "lodash",
5855
"message": "Import specific methods from `lodash`. e.g. `import map from 'lodash/map'`"
@@ -62,7 +59,6 @@
6259
"importNames": ["default"],
6360
"message": "Import specific methods from `lodash-es`. e.g. `import { map } from 'lodash-es'`"
6461
},
65-
// These two rules ensure that we're importing Carbon components and icons from the correct packages (after v10). May be removed in the future.
6662
{
6763
"name": "carbon-components-react",
6864
"message": "Import from `@carbon/react` directly. e.g. `import { Toggle } from '@carbon/react'`"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@
7575
"@types/react": "^18.3.21",
7676
"@types/react-dom": "^18.3.0",
7777
"@types/webpack-env": "^1.18.4",
78-
"@typescript-eslint/eslint-plugin": "^6.19.1",
79-
"@typescript-eslint/parser": "^6.19.1",
78+
"@typescript-eslint/eslint-plugin": "^8.0.0",
79+
"@typescript-eslint/parser": "^8.0.0",
8080
"babel-preset-minify": "^0.5.2",
8181
"concurrently": "^8.2.2",
8282
"cross-env": "^7.0.3",
8383
"css-loader": "^6.9.1",
8484
"d3-selection": "^3.0.0",
8585
"dayjs": "^1.11.10",
8686
"dotenv": "^16.4.1",
87-
"eslint": "^8.56.0",
87+
"eslint": "^8.57.0",
8888
"eslint-plugin-import": "^2.31.0",
8989
"eslint-plugin-jest-dom": "^5.5.0",
9090
"eslint-plugin-playwright": "^2.2.2",

src/bill-history/bill-history.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const BillHistory: React.FC<BillHistoryProps> = ({ patientUuid }) => {
7373
if (isLoading) {
7474
return (
7575
<div className={styles.loaderContainer}>
76-
<DataTableSkeleton showHeader={false} showToolbar={false} zebra size="md" />
76+
<DataTableSkeleton showHeader={false} showToolbar={false} zebra />
7777
</div>
7878
);
7979
}

src/bill-history/bill-history.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useBills } from '../billing.resource';
77
import BillHistory from './bill-history.component';
88

99
const mockUseConfig = jest.mocked(useConfig<BillingConfig>);
10-
const mockUseBills = jest.mocked(useBills);
10+
const mockUseBills = jest.mocked<typeof useBills>(useBills);
1111

1212
jest.mock('../billing.resource', () => ({
1313
useBills: jest.fn(() => ({

src/billable-services-admin-card-link.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const BillableServicesCardLink: React.FC = () => {
99

1010
return (
1111
<Layer>
12-
<ClickableTile href={`${window.spaBase}/billable-services`} target="_blank" rel="noopener noreferrer">
12+
<ClickableTile href={`${window.spaBase}/billable-services`}>
1313
<div>
1414
<div className="heading">{header}</div>
1515
<div className="content">{t('billableServices', 'Billable services')}</div>

src/billable-services/bill-waiver/bill-waiver-form.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const BillWaiverForm: React.FC<BillWaiverFormProps> = ({ bill, lineItems, setPat
6565
<Form className={styles.billWaiverForm} aria-label={t('waiverForm', 'Waiver form')}>
6666
<hr />
6767
<Stack gap={7}>
68-
<FormGroup>
68+
<FormGroup legendText="">
6969
<section className={styles.billWaiverDescription}>
7070
<label className={styles.label}>{t('billItems', 'Bill Items')}</label>
7171
<p className={styles.value}>
@@ -81,6 +81,7 @@ const BillWaiverForm: React.FC<BillWaiverFormProps> = ({ bill, lineItems, setPat
8181

8282
<Layer className={styles.formControlLayer}>
8383
<NumberInput
84+
id="waiver-amount"
8485
allowEmpty
8586
aria-label={t('amountToWaiveAriaLabel', 'Enter amount to waive')}
8687
disableWheel
@@ -90,7 +91,7 @@ const BillWaiverForm: React.FC<BillWaiverFormProps> = ({ bill, lineItems, setPat
9091
label={t('amountToWaiveLabel', 'Amount to waive')}
9192
max={totalAmount}
9293
min={0}
93-
onChange={(event) => setWaiverAmount(event.target.value)}
94+
onChange={(_, { value }) => setWaiverAmount(value as number)}
9495
value={waiverAmount}
9596
/>
9697
</Layer>

src/billable-services/billable-service-form/billable-service-form.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ describe('BillableServiceFormWorkspace', () => {
217217
expect(saveButton).toBeDisabled();
218218
expect(cancelButton).toBeDisabled();
219219

220-
// Resolve the promise to complete submission
221220
resolveCreate!({} as FetchResponse<any>);
222-
await new Promise((resolve) => setTimeout(resolve, 100));
221+
await waitFor(() => {
222+
expect(saveButton).toBeDisabled();
223+
});
223224
});
224225

225226
test('should show loading indicator in save button during submission', async () => {
@@ -242,7 +243,9 @@ describe('BillableServiceFormWorkspace', () => {
242243

243244
// Resolve the promise
244245
resolveCreate!({} as FetchResponse<any>);
245-
await new Promise((resolve) => setTimeout(resolve, 100));
246+
await waitFor(() => {
247+
expect(screen.queryByText(/saving/i)).not.toBeInTheDocument();
248+
});
246249
});
247250

248251
test('should call onWorkspaceClose callback after successful edit', async () => {

src/billable-services/billable-service-form/billable-service-form.workspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ const BillableServiceFormWorkspace: React.FC<Workspace2DefinitionProps<BillableS
512512
</section>
513513
</Stack>
514514
<ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
515-
<Button className={styles.button} kind="secondary" disabled={isSubmitting} onClick={closeWorkspace}>
515+
<Button className={styles.button} kind="secondary" disabled={isSubmitting} onClick={() => closeWorkspace()}>
516516
{getCoreTranslation('cancel')}
517517
</Button>
518518
<Button className={styles.button} kind="primary" disabled={isSubmitting} type="submit">

src/bills-table/bills-table.component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ const BillsTable: React.FC = () => {
166166
showToolbar={false}
167167
zebra
168168
columnCount={headerData?.length}
169-
size={responsiveSize}
170169
/>
171170
</div>
172171
) : error ? (
@@ -269,7 +268,7 @@ interface FilterableTableHeaderProps {
269268
layout: LayoutType;
270269
handleSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
271270
isValidating: boolean;
272-
responsiveSize: 'sm' | 'md' | 'lg' | 'xl';
271+
responsiveSize: 'sm' | 'md' | 'lg';
273272
searchString: string;
274273
t: (key: string, fallback: string) => string;
275274
}

src/declarations.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
declare module '*.css';
22
declare module '*.scss';
3-
declare module '@carbon/react';
4-
declare type SideNavProps = object;

0 commit comments

Comments
 (0)