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) Various tooling updates and tweaks #73

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Conversation

denniskigen
Copy link
Member

@denniskigen denniskigen commented Dec 5, 2024

Requirements

  • This PR has a title that briefly describes the work done including a conventional commit type prefix and a Jira ticket number if applicable. See existing PR titles for inspiration.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.

Summary

This PR introduces several improvements to our tooling setup:

  • Standardized ESLint Configuration: Aligns the ESLint configuration with the standards used in other O3 repositories for consistency.
  • Pre-commit Hook Enhancements: Separates linting and formatting tasks in the pre-commit hook to adhere to best practices, ensuring clearer and more efficient code checks.
  • Version Updates: Updates core tooling versions, including Turbo and Yarn, to leverage the latest features and improvements.
  • Refactoring: A significant portion of the code changes are due to refactoring necessary to address violations of React's rules of hooks, as identified by the ESLint React Hooks plugin.

Screenshots

Related Issue

Other

@@ -1,2 +1 @@
src/**/*.test.tsx
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason why we shouldn't lint test files.

// Control the line ending. See options at https://github.com/ryanve/eol

locales: ["en", "am", "es", "fr", "km", "he"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only want to extract en translations and use those as the source of truth. We use the Transifex integration as the source of truth for non English locales.

@@ -4,6 +4,7 @@
const path = require('path');

module.exports = {
clearMocks: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So mocks gets automatically cleared between test runs.

};
}, [
getValues,
patientCatergory.insuranceScheme,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: We need to fix this typo in a subsequent commit. It's coming from the config schema so we need to figure out what the blast radius of this change will be beforehand.

Comment on lines -71 to -74
{
"name": "require-billing-modal",
"component": "requirePaymentModal"
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modals should be registered under the modals key.

Comment on lines 3 to +16
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "react",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"module": "esnext",
"moduleResolution": "node",
"module": "ESNext",
"noEmit": true,
"lib": ["es2022", "dom", "dom.iterable"],
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "esnext"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reorganized for sanity.

},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add plugin:jest-dom/recommended and plugin:testing-library/react?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. Only reason I didn't is because I want to keep the diff small

"project": true,
"tsconfigRootDir": "__dirname"
},
"plugins": ["@typescript-eslint", "import", "react-hooks"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if its a standard or if we should do it but we have testing-library added as a plugin in patient-chart and form-builder but not core

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add the import plugin as well, to flag duplicate imports?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already in there

import { getBillableServiceUuid } from '../invoice/payments/utils';
import { type LineItem, type MappedBill } from '../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type LineItem, type MappedBill } from '../types';
import type { LineItem, MappedBill } from '../types';

import { showSnackbar } from '@openmrs/esm-framework';
import { type LineItem, type MappedBill } from '../types';
import { type MappedBill } from '../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type MappedBill } from '../types';
import type { MappedBill } from '../types';

Tile,
} from '@carbon/react';
import { ArrowRight } from '@carbon/react/icons';
import { useLayoutType, isDesktop, useConfig, usePagination, ErrorState, navigate } from '@openmrs/esm-framework';
import { EmptyState } from '@openmrs/esm-patient-common-lib';
import { type BillableService } from '../types/index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type BillableService } from '../types/index';
import type { BillableService } from '../types/index';

import { apiBasePath } from '../constants';
import isEmpty from 'lodash-es/isEmpty';
import { convertToCurrency } from '../helpers';
import { type BillabeItem } from '../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type BillabeItem } from '../types';
import type { BillabeItem } from '../types';

@@ -1,6 +1,4 @@
import { type Payment, type LineItem } from '../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type Payment, type LineItem } from '../types';
import type { Payment, LineItem } from '../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please feel free to ignore the type import suggestions, we can always do them later on if this needs to go in asap!

import { showModal, useConfig, useDebounce } from '@openmrs/esm-framework';
import { useTranslation } from 'react-i18next';
import { MappedBill } from '../types';
import { type MappedBill } from '../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type MappedBill } from '../types';
import type { MappedBill } from '../types';

import { useConfig } from '@openmrs/esm-framework';
import { MappedBill } from '../../../types';
import PaymentHistory from './payment-history.component';
import { type MappedBill } from '../../../types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { type MappedBill } from '../../../types';
import type { MappedBill } from '../../../types';

Copy link

@NethmiRodrigo NethmiRodrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @denniskigen! LGTM! Left some comments of a couple of nitpicks and questions I had about the imports in .eslintrc

Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -1,17 +1,39 @@
{
"env": {
"node": true,
"browser": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this disable global browser-specific variables like console, window etc.?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so, no. We don't have that elsewhere AFAICT.

@denniskigen denniskigen merged commit ab6f516 into main Dec 6, 2024
5 checks passed
@denniskigen denniskigen deleted the chore/tooling branch December 6, 2024 08:27
@denniskigen
Copy link
Member Author

Thanks for the reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants