Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore) Enforce consistent usage of type imports #242

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"project": true,
"tsconfigRootDir": "__dirname"
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"@typescript-eslint/ban-types": "off",
Expand All @@ -24,7 +22,7 @@
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/consistent-type-imports": [
"off",
"error",
{
"fixStyle": "inline-type-imports"
}
Expand Down
6 changes: 2 additions & 4 deletions src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fhirBaseUrl, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import { encounterRepresentation } from '../constants';
import { OpenmrsForm, PatientIdentifier, ProgramEnrollmentPayload } from '../types';
import { type OpenmrsForm, type PatientIdentifier, type ProgramEnrollmentPayload } from '../types';
import { isUuid } from '../utils/boolean-utils';

export function saveEncounter(abortController: AbortController, payload, encounterUuid?: string) {
Expand Down Expand Up @@ -190,7 +190,7 @@ export function updateProgramEnrollment(
});
}

export function savePatientIdentifier(patientIdentifier:PatientIdentifier, patientUuid: string){
export function savePatientIdentifier(patientIdentifier: PatientIdentifier, patientUuid: string) {
let url: string;

if (patientIdentifier.uuid) {
Expand All @@ -207,5 +207,3 @@ export function savePatientIdentifier(patientIdentifier:PatientIdentifier, patie
body: JSON.stringify(patientIdentifier),
});
}


8 changes: 4 additions & 4 deletions src/components/encounter/encounter-form.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } from 'react';
import { SessionLocation, showToast, showSnackbar, useLayoutType, Visit } from '@openmrs/esm-framework';
import React, { type Dispatch, type SetStateAction, useCallback, useEffect, useMemo, useState } from 'react';
import { type SessionLocation, showToast, showSnackbar, useLayoutType, type Visit } from '@openmrs/esm-framework';
import { codedTypes, ConceptFalse, ConceptTrue } from '../../constants';
import {
import type {
FormField,
FormPage as FormPageProps,
FormSchema,
Expand All @@ -22,7 +22,7 @@ import {
voidObsValueOnFieldHidden,
} from '../../utils/form-helper';
import { InstantEffect } from '../../utils/instant-effect';
import { FormSubmissionHandler } from '../../form-engine.component';
import { type FormSubmissionHandler } from '../../form-engine.component';
import { evaluateAsyncExpression, evaluateExpression } from '../../utils/expression-runner';
import { getPreviousEncounter, saveAttachment, saveEncounter } from '../../api/api';
import { isTrue } from '../../utils/boolean-utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/extension/extension-parcel.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useMemo } from 'react';
import { BehaviorSubject } from 'rxjs';
import { attach, ExtensionSlot } from '@openmrs/esm-framework';
import { FormContext } from '../../form-context';
import { FormFieldProps } from '../../types';
import { type FormFieldProps } from '../../types';

const ExtensionParcel: React.FC<FormFieldProps> = ({ question }) => {
const { encounterContext, isSubmitting } = useContext(FormContext);
Expand Down
2 changes: 1 addition & 1 deletion src/components/group/obs-group.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from 'react';
import classNames from 'classnames';
import { useField } from 'formik';
import { FormContext } from '../../form-context';
import { FormFieldProps } from '../../types';
import { type FormFieldProps } from '../../types';
import { getFieldControlWithFallback, isUnspecifiedSupported } from '../section/helpers';
import { UnspecifiedField } from '../inputs/unspecified/unspecified.component';
import { Tooltip } from '../inputs/tooltip/tooltip.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isEmpty } from '../../../validators/form-validator';
import { isTrue } from '../../../utils/boolean-utils';
import { FieldValueView } from '../../value/view/field-value-view.component';
import { FormContext } from '../../../form-context';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import styles from './content-switcher.scss';
import { useTranslation } from 'react-i18next';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { render, fireEvent, screen, cleanup, act, waitFor } from '@testing-library/react';
import { Formik } from 'formik';
import { ContentSwitcher } from './content-switcher.component';
import { EncounterContext, FormContext } from '../../../form-context';
import { FormField } from '../../../types';
import { type EncounterContext, FormContext } from '../../../form-context';
import { type FormField } from '../../../types';
import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers';

const question: FormField = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/date/date.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useField } from 'formik';
import { DatePicker, DatePickerInput, Layer, TimePicker } from '@carbon/react';
import { formatDate } from '@openmrs/esm-framework';
import { isTrue } from '../../../utils/boolean-utils';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { isInlineView } from '../../../utils/form-helper';
import { FieldValueView } from '../../value/view/field-value-view.component';
import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/file/file.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Camera from '../camera/camera.component';
import { Close, DocumentPdf } from '@carbon/react/icons';
import styles from './file.scss';
import { createAttachment } from '../../../utils/common-utils';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { FormContext } from '../../../form-context';
import { isInlineView } from '../../../utils/form-helper';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import isObject from 'lodash-es/isObject';
import { isEmpty } from '../../../validators/form-validator';
import { isTrue } from '../../../utils/boolean-utils';
import { FormContext } from '../../../form-context';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';

const FixedValue: React.FC<FormFieldProps> = ({ question, handler }) => {
const { encounterContext, isFieldInitializationComplete } = React.useContext(FormContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createErrorHandler } from '@openmrs/esm-framework';
import { getAllLocations, getLocationsByTag } from '../../../api/api';
import { isInlineView } from '../../../utils/form-helper';
import { isTrue } from '../../../utils/boolean-utils';
import { FormField } from '../../../types';
import { type FormField } from '../../../types';
import { FormContext } from '../../../form-context';
import { FieldValueView } from '../../value/view/field-value-view.component';
import styles from './encounter-location.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/markdown/markdown.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import MarkdownWrapper from './markdown-wrapper.component';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';

const Markdown: React.FC<FormFieldProps> = ({ question }) => {
return !question.isHidden && <MarkdownWrapper markdown={question.value} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mockVisit } from '../../../../__mocks__/visit.mock';
import multiSelectFormSchema from '../../../../__mocks__/forms/rfe-forms/multi-select-form.json';
import { mockPatient } from '../../../../__mocks__/patient.mock';
import { mockSessionDataResponse } from '../../../../__mocks__/session.mock';
import { FormSchema } from '../../../types';
import { type FormSchema } from '../../../types';
import FormEngine from '../../../form-engine.component';

const mockOpenmrsFetch = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useField } from 'formik';
import { useTranslation } from 'react-i18next';
import { FieldValueView } from '../../value/view/field-value-view.component';
import { FormContext } from '../../../form-context';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { ValueEmpty } from '../../value/value.component';
import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator';
import { isInlineView } from '../../../utils/form-helper';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/number/number.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isTrue } from '../../../utils/boolean-utils';
import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator';
import { isInlineView } from '../../../utils/form-helper';
import { FieldValueView } from '../../value/view/field-value-view.component';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { FormContext } from '../../../form-context';
import RequiredFieldLabel from '../../required-field-label/required-field-label.component';
import styles from './number.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/radio/radio.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { FormGroup, RadioButtonGroup, RadioButton } from '@carbon/react';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { useField } from 'formik';
import { FormContext } from '../../../form-context';
import { isTrue } from '../../../utils/boolean-utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/select/dropdown.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isInlineView } from '../../../utils/form-helper';
import { isTrue } from '../../../utils/boolean-utils';
import { FieldValueView } from '../../value/view/field-value-view.component';
import { FormContext } from '../../../form-context';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import RequiredFieldLabel from '../../required-field-label/required-field-label.component';
import styles from './dropdown.scss';

Expand Down
4 changes: 2 additions & 2 deletions src/components/inputs/select/dropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { render, fireEvent, screen, cleanup, act } from '@testing-library/react';
import { Formik } from 'formik';
import { EncounterContext, FormContext } from '../../../form-context';
import { type EncounterContext, FormContext } from '../../../form-context';
import Dropdown from './dropdown.component';
import { FormField } from '../../../types';
import { type FormField } from '../../../types';
import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers';

const question: FormField = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/text-area/text-area.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isInlineView } from '../../../utils/form-helper';
import { isTrue } from '../../../utils/boolean-utils';
import { FieldValueView } from '../../value/view/field-value-view.component';
import { FormContext } from '../../../form-context';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import RequiredFieldLabel from '../../required-field-label/required-field-label.component';
import styles from './text-area.scss';
import { useTranslation } from 'react-i18next';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/text/text.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames';
import isEmpty from 'lodash-es/isEmpty';
import { Layer, TextInput } from '@carbon/react';
import { useField } from 'formik';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { FormContext } from '../../../form-context';
import { fieldRequiredErrCode } from '../../../validators/form-validator';
import { isTrue } from '../../../utils/boolean-utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/toggle/toggle.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useState } from 'react';
import { Toggle as ToggleInput } from '@carbon/react';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { useField } from 'formik';
import { FormContext } from '../../../form-context';
import { isTrue } from '../../../utils/boolean-utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/tooltip/tooltip.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Tooltip as CarbonTooltip } from '@carbon/react';
import { Information } from '@carbon/react/icons';
import { FormField } from '../../../types';
import { type FormField } from '../../../types';
import styles from './tooltip.scss';
import { useTranslation } from 'react-i18next';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next';
import { getRegisteredDataSource } from '../../../registry/registry';
import { getControlTemplate } from '../../../registry/inbuilt-components/control-templates';
import { FormContext } from '../../../form-context';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { fieldRequiredErrCode, isEmpty } from '../../../validators/form-validator';
import { isInlineView } from '../../../utils/form-helper';
import RequiredFieldLabel from '../../required-field-label/required-field-label.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { render, fireEvent, waitFor, act, screen } from '@testing-library/react';
import UiSelectExtended from './ui-select-extended.component';
import { EncounterContext, FormContext } from '../../../form-context';
import { type EncounterContext, FormContext } from '../../../form-context';
import { Formik } from 'formik';
import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers';
import { FormField } from '../../../types';
import { type FormField } from '../../../types';

const question: FormField = {
label: 'Transfer Location',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useField } from 'formik';
import { useTranslation } from 'react-i18next';
import { FormContext } from '../../../form-context';
import { FieldValidator } from '../../../validators/form-validator';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import { isTrue } from '../../../utils/boolean-utils';
import styles from './unspecified.scss';

Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/unspecified/unspecified.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { Formik } from 'formik';
import { FormField, EncounterContext, FormContext } from '../../..';
import { type FormField, type EncounterContext, FormContext } from '../../..';
import { ObsSubmissionHandler } from '../../../submission-handlers/base-handlers';
import { UnspecifiedField } from './unspecified.component';
import { findTextOrDateInput } from '../../../utils/test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import { showSnackbar } from '@openmrs/esm-framework';
import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib';
import { Button } from '@carbon/react';
import { FormFieldProps } from '../../../types';
import { type FormFieldProps } from '../../../types';
import styles from './workspace-launcher.scss';

const WorkspaceLauncher: React.FC<FormFieldProps> = ({ question }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/repeat/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cloneDeep } from 'lodash-es';
import { FormField } from '../../types';
import { type FormField } from '../../types';

export function cloneObsGroup(srcField: FormField, obsGroup: any, idSuffix: number) {
const originalGroupMembersIds: string[] = [];
Expand Down
9 changes: 2 additions & 7 deletions src/components/repeat/repeat.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormGroup, Button } from '@carbon/react';
import { Add, TrashCan } from '@carbon/react/icons';
import { useFormikContext } from 'formik';
import { useTranslation } from 'react-i18next';
import { FormField, FormFieldProps } from '../../types';
import { type FormField, type FormFieldProps } from '../../types';
import { evaluateAsyncExpression, evaluateExpression } from '../../utils/expression-runner';
import { ObsGroup } from '../group/obs-group.component';
import { isEmpty } from '../../validators/form-validator';
Expand All @@ -20,12 +20,7 @@ const Repeat: React.FC<FormFieldProps> = ({ question, onChange }) => {
const { t } = useTranslation();
const id = useId();

const {
fields: allFormFields,
encounterContext,
obsGroupsToVoid,
formFieldHandlers,
} = React.useContext(FormContext);
const { fields: allFormFields, encounterContext, obsGroupsToVoid, formFieldHandlers } = React.useContext(FormContext);
const { values, setValues } = useFormikContext();
const [counter, setCounter] = useState(1);
const [obsGroups, setObsGroups] = useState([]);
Expand Down
6 changes: 3 additions & 3 deletions src/components/section/form-section.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React, { useEffect, useState } from 'react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useField } from 'formik';
import type { FormField, FormFieldProps, previousValue, SubmissionHandler } from '../../types';
import { ErrorBoundary } from 'react-error-boundary';
import { ToastNotification } from '@carbon/react';
import { getRegisteredFieldSubmissionHandler } from '../../registry/registry';
import { formatPreviousValueDisplayText, getFieldControlWithFallback, isUnspecifiedSupported } from './helpers';
import { PreviousValueReview } from '../previous-value-review/previous-value-review.component';
import { getRegisteredFieldSubmissionHandler } from '../../registry/registry';
import { isTrue } from '../../utils/boolean-utils';
import { UnspecifiedField } from '../inputs/unspecified/unspecified.component';
import { FormField, FormFieldProps, previousValue, SubmissionHandler } from '../../types';
import { FormContext } from '../../form-context';
import { PreviousValueReview } from '../previous-value-review/previous-value-review.component';
import { Tooltip } from '../inputs/tooltip/tooltip.component';
import styles from './form-section.scss';

Expand Down
2 changes: 1 addition & 1 deletion src/components/section/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatDate } from '@openmrs/esm-framework';
import { getRegisteredControl } from '../../registry/registry';
import { isTrue } from '../../utils/boolean-utils';
import { FormField } from '../../types';
import { type FormField } from '../../types';

/**
* Retrieves the appropriate field control for a question, considering missing concepts.
Expand Down
6 changes: 3 additions & 3 deletions src/components/sidebar/sidebar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isEmpty } from '../../validators/form-validator';
import { scrollIntoView } from '../../utils/scroll-into-view';
import styles from './sidebar.scss';

function Sidebar({
const Sidebar = ({
isFormSubmitting,
pagesWithErrors,
scrollablePages,
Expand All @@ -18,7 +18,7 @@ function Sidebar({
setValues,
allowUnspecifiedAll,
defaultPage,
}) {
}) => {
const { t } = useTranslation();
const [activeLink, setActiveLink] = useState(selectedPage);

Expand Down Expand Up @@ -120,6 +120,6 @@ function Sidebar({
</div>
</div>
);
}
};

export default Sidebar;
4 changes: 2 additions & 2 deletions src/datasources/data-source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { openmrsFetch, OpenmrsResource } from '@openmrs/esm-framework';
import { DataSource } from '../types';
import { openmrsFetch, type OpenmrsResource } from '@openmrs/esm-framework';
import { type DataSource } from '../types';

export class BaseOpenMRSDataSource implements DataSource<OpenmrsResource> {
url: string;
Expand Down
10 changes: 8 additions & 2 deletions src/form-context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from 'react';
import { LayoutType } from '@openmrs/esm-framework';
import { FormField, OpenmrsEncounter, PatientIdentifier, SessionMode, SubmissionHandler } from './types';
import { type LayoutType } from '@openmrs/esm-framework';
import {
type FormField,
type OpenmrsEncounter,
type PatientIdentifier,
type SessionMode,
type SubmissionHandler,
} from './types';

type FormContextProps = {
values: Record<string, any>;
Expand Down
Loading
Loading