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

Feat: Disallow Relative import #10009

Merged
merged 30 commits into from
Jan 20, 2025

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Jan 16, 2025

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • Chores

    • Updated import paths across multiple files to use absolute imports with @/ prefix
    • Added ESLint plugin no-relative-import-paths to enforce import path consistency
    • Added new dev dependency eslint-plugin-no-relative-import-paths
  • New Features

    • Enhanced import path management and code organization
    • Improved code linting capabilities with new ESLint rules
    • Added new API endpoints for managing organization-related data in the questionnaire
    • Introduced tooltip functionality in the Medication Statement List component

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner January 16, 2025 09:00
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Warning

Rate limit exceeded

@AdityaJ2305 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 40 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7eae09e and 086b795.

📒 Files selected for processing (1)
  • src/types/emr/encounter.ts (1 hunks)

Walkthrough

This pull request introduces a comprehensive update to the project's import strategy and ESLint configuration. The primary focus is on standardizing import paths by replacing relative imports with absolute imports using the @/ prefix. Additionally, a new ESLint plugin no-relative-import-paths has been added to enforce stricter import path rules. The changes span multiple files across components, types, and utility modules, ensuring a more consistent and maintainable import structure throughout the project.

Changes

File/Path Change Summary
.eslintrc.json Added no-relative-import-paths plugin and configured import path rules
package.json Added eslint-plugin-no-relative-import-paths as a dev dependency
src/components/* Updated multiple import paths from relative to absolute using @/ prefix
src/types/* Standardized import paths for various type definitions
src/Routers/AppRouter.tsx Minor type definition adjustment

Assessment against linked issues

Objective Addressed Explanation
Update eslint configurations to disallow relative imports
Resolve newly observed eslint errors

Possibly related PRs

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 Imports dance in absolute grace,
No more relative paths to chase!
With @/ as our guiding light,
Code structure becomes so bright!
A rabbit's leap to cleaner code, hooray! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 086b795
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/678e29659cc53300089e871a
😎 Deploy Preview https://deploy-preview-10009--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AdityaJ2305 AdityaJ2305 marked this pull request as draft January 16, 2025 09:12
@AdityaJ2305 AdityaJ2305 marked this pull request as ready for review January 16, 2025 09:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/components/Patient/MedicationStatementList.tsx (1)

Line range hint 93-93: Add missing key prop to TableRow component.

When mapping over an array to create elements, each element needs a unique key prop for React's reconciliation process.

-              <TableRow>
+              <TableRow key={statement.id ?? `medication-${index}`}>
🧹 Nitpick comments (4)
src/components/Patient/MedicationStatementList.tsx (2)

Line range hint 147-156: Standardize null value handling between trigger and tooltip content.

The trigger shows "-" for null values while the tooltip content shows "Not Specified". This inconsistency might confuse users. Consider standardizing the fallback text.

                  <Tooltip>
                    <TooltipTrigger asChild className="max-w-60 truncate">
-                      <p>{statement.reason ?? "-"}</p>
+                      <p>{statement.reason ?? "Not Specified"}</p>
                    </TooltipTrigger>
                    <TooltipContent>
                      <p>{statement.reason ?? "Not Specified"}</p>
                    </TooltipContent>
                  </Tooltip>

Also applies to: 166-175


Line range hint 94-156: Enhance tooltip accessibility.

Consider adding aria-label to tooltip triggers to improve screen reader experience. Also, ensure the truncated text is clearly indicated to users.

Example for medication name:

                  <Tooltip>
                    <TooltipTrigger 
                      asChild 
                      className="max-w-60 truncate"
+                     aria-label={`Medication name: ${statement.medication.display ?? statement.medication.code}`}
                    >
src/types/questionnaire/questionnaireApi.ts (1)

Line range hint 77-83: Use consistent type definition pattern for setOrganizations endpoint.

While the endpoint implementation is correct, the request body type definition uses a different pattern from other endpoints. For consistency and better type safety, consider using the Type utility.

  setOrganizations: {
    path: "/api/v1/questionnaire/{id}/set_organizations/",
    method: HttpMethod.POST,
    TRes: Type<PaginatedResponse<Organization>>(),
-   TBody: {} as { organizations: string[] },
+   TBody: Type<{ organizations: string[] }>(),
  },
package.json (1)

Line range hint 1-102: Consider a phased migration approach for relative imports.

To ensure a smooth transition to absolute imports:

  1. Consider adding a script to automate the conversion of relative imports to absolute paths
  2. Update the CI pipeline to:
    • Initially run the rule in warning mode
    • After a grace period, enforce as errors
  3. Document the new import convention in the project's coding guidelines

This will help manage the migration process and reduce developer friction.

Would you like me to help create a migration script to automate the conversion of relative imports to absolute paths?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed7243e and 943a999.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (35)
  • .eslintrc.json (3 hunks)
  • package.json (1 hunks)
  • src/Routers/routes/questionnaireRoutes.tsx (1 hunks)
  • src/components/Common/Charts/ObservationChart.tsx (1 hunks)
  • src/components/Common/Charts/ObservationHistoryTable.tsx (1 hunks)
  • src/components/Facility/DuplicatePatientDialog.tsx (1 hunks)
  • src/components/Facility/EncounterCard.tsx (1 hunks)
  • src/components/Files/AudioCaptureDialog.tsx (1 hunks)
  • src/components/Patient/MedicationStatementList.tsx (1 hunks)
  • src/components/Patient/PatientDetailsTab/HealthProfileSummary.tsx (1 hunks)
  • src/components/Patient/PatientRegistration.tsx (1 hunks)
  • src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx (1 hunks)
  • src/components/Questionnaire/QuestionnaireEditor.tsx (1 hunks)
  • src/components/Questionnaire/index.tsx (1 hunks)
  • src/components/Questionnaire/show.tsx (1 hunks)
  • src/components/Resource/ResourceCommentSection.tsx (1 hunks)
  • src/components/Resource/ResourceDetails.tsx (1 hunks)
  • src/components/Users/UserSummary.tsx (1 hunks)
  • src/components/ui/sidebar/patient-switcher.tsx (1 hunks)
  • src/pages/Facility/FacilitiesPage.tsx (1 hunks)
  • src/pages/Facility/components/FacilityCard.tsx (1 hunks)
  • src/pages/PublicAppointments/PatientRegistration.tsx (1 hunks)
  • src/types/emr/allergyIntolerance/allergyIntolerance.ts (1 hunks)
  • src/types/emr/diagnosis/diagnosis.ts (1 hunks)
  • src/types/emr/encounter.ts (1 hunks)
  • src/types/emr/newPatient.ts (1 hunks)
  • src/types/emr/observation.ts (1 hunks)
  • src/types/emr/symptom/symptom.ts (1 hunks)
  • src/types/facility/facility.ts (1 hunks)
  • src/types/facilityOrganization/facilityOrganization.ts (1 hunks)
  • src/types/organization/organization.ts (1 hunks)
  • src/types/organization/organizationApi.ts (1 hunks)
  • src/types/questionnaire/questionnaireApi.ts (1 hunks)
  • src/types/questionnaire/questionnaireResponse.ts (1 hunks)
  • src/types/resourceRequest/resourceRequest.ts (1 hunks)
✅ Files skipped from review due to trivial changes (29)
  • src/types/facilityOrganization/facilityOrganization.ts
  • src/Routers/routes/questionnaireRoutes.tsx
  • src/components/Users/UserSummary.tsx
  • src/types/facility/facility.ts
  • src/components/Resource/ResourceCommentSection.tsx
  • src/components/Facility/EncounterCard.tsx
  • src/types/resourceRequest/resourceRequest.ts
  • src/components/Common/Charts/ObservationHistoryTable.tsx
  • src/types/emr/observation.ts
  • src/components/ui/sidebar/patient-switcher.tsx
  • src/components/Common/Charts/ObservationChart.tsx
  • src/components/Patient/PatientRegistration.tsx
  • src/types/emr/newPatient.ts
  • src/components/Questionnaire/show.tsx
  • src/types/questionnaire/questionnaireResponse.ts
  • src/components/Questionnaire/index.tsx
  • src/types/organization/organization.ts
  • src/components/Resource/ResourceDetails.tsx
  • src/components/Questionnaire/QuestionnaireEditor.tsx
  • src/pages/Facility/components/FacilityCard.tsx
  • src/types/emr/allergyIntolerance/allergyIntolerance.ts
  • src/components/Files/AudioCaptureDialog.tsx
  • src/types/emr/diagnosis/diagnosis.ts
  • src/components/Facility/DuplicatePatientDialog.tsx
  • src/types/emr/encounter.ts
  • src/pages/Facility/FacilitiesPage.tsx
  • src/types/emr/symptom/symptom.ts
  • src/pages/PublicAppointments/PatientRegistration.tsx
  • src/components/Patient/PatientDetailsTab/HealthProfileSummary.tsx
🔇 Additional comments (8)
src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx (1)

13-13: LGTM! Import path standardization looks good.

The update from relative path to absolute path using @/ prefix aligns with the PR objective of standardizing imports across the codebase.

src/types/organization/organizationApi.ts (1)

3-3: LGTM! Import path updated to use absolute path.

The change from relative to absolute import path aligns with the PR objective and maintains consistency with other imports in the file.

Let's verify the TypeScript path alias configuration:

✅ Verification successful

Import path configuration verified successfully

The TypeScript path alias configuration correctly maps @/* to ./src/*, and the target file exists at the expected path src/types/emr/newPatient.ts. The absolute import path is properly configured and will resolve correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify TypeScript path alias configuration for absolute imports

# Check tsconfig.json for path alias configuration
echo "Checking tsconfig.json for '@' path alias..."
cat tsconfig.json | jq '.compilerOptions.paths'

# Verify that the target file exists at the expected path
echo "Verifying the imported file exists..."
fd "newPatient.ts" --type f

Length of output: 405

src/components/Patient/MedicationStatementList.tsx (1)

17-21: LGTM! Import changes align with the standardization effort.

The new tooltip component imports follow the absolute path pattern using @/ prefix, maintaining consistency with the project's import standardization initiative.

src/types/questionnaire/questionnaireApi.ts (2)

3-3: LGTM! Import path standardization looks good.

The change to use absolute import path with @/ prefix aligns with the PR objective of standardizing imports across the codebase.


Line range hint 71-83: Verify path parameter naming consistency across API endpoints.

The new endpoints use {id} as the path parameter, which matches other endpoints in this file. Let's verify this is consistent across the codebase.

✅ Verification successful

Path parameter naming is consistent with the system design

The different parameter names ({id} vs {slug}) in the questionnaire API endpoints are intentionally designed this way, as the tags-related endpoints consistently use slugs while other questionnaire operations use IDs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for API endpoint definitions to verify path parameter naming consistency
rg -g '*.ts' -g '*.tsx' '/api/v\d+/[^"]+/\{[^}]+\}/' --no-heading

Length of output: 8372

.eslintrc.json (2)

45-46: LGTM! Plugin addition looks good.

The no-relative-import-paths plugin is correctly added to the plugins array.


82-87: Verify the rule configuration impact.

The rule configuration looks good with appropriate settings:

  • Error level enforcement ensures strict adoption
  • allowSameFolder: true provides practical flexibility
  • prefix: "@" standardizes absolute imports

However, let's verify the potential impact on the codebase.

✅ Verification successful

ESLint rule configuration is safe to implement

The rule configuration perfectly aligns with your existing TypeScript path aliases and current codebase practices. No relative imports were found that would break under this rule, indicating zero migration effort needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for existing relative imports that would break under the new rule
# This helps assess the migration effort needed

# Search for relative imports (../ or ./)
echo "Checking for relative imports that need to be updated:"
rg "from ['\"]\.\.?/" --type ts --type tsx

# Count total occurrences
echo -e "\nTotal count of files with relative imports:"
rg "from ['\"]\.\.?/" --type ts --type tsx --count | wc -l

Length of output: 389


Script:

#!/bin/bash

# Check for relative imports in JS/TS files
echo "Files with relative imports:"
rg "from ['\"]\.\.?/" -t js -t jsx -t ts -t mjs -t cjs -C 1

# Check for tsconfig.json and package.json
echo -e "\nChecking for TypeScript configuration:"
fd tsconfig.json

echo -e "\nChecking package.json:"
cat package.json | jq '.dependencies, .devDependencies'

Length of output: 4725


Script:

#!/bin/bash

# Search for relative imports with simpler pattern and correct syntax
echo "Checking for relative imports:"
rg "from '\.\." --type=js --type=ts

echo -e "\nChecking root tsconfig.json for path aliases:"
cat tsconfig.json | jq '.compilerOptions.paths'

Length of output: 378

package.json (1)

158-158: LGTM! Dependency addition is correct.

The ESLint plugin is:

  • Added to the correct section (devDependencies)
  • Uses appropriate version range (^1.6.1)
  • Properly sorted alphabetically

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 17, 2025
Copy link

👋 Hi, @AdityaJ2305,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Jan 17, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/types/questionnaire/questionnaireApi.ts (1)

Line range hint 74-84: Use Type utility for request body type definition.

The setOrganizations endpoint uses a runtime type assertion for TBody. This should be consistent with other endpoints by using the Type utility.

Apply this change:

  setOrganizations: {
    path: "/api/v1/questionnaire/{id}/set_organizations/",
    method: HttpMethod.POST,
    TRes: Type<PaginatedResponse<Organization>>(),
-   TBody: {} as { organizations: string[] },
+   TBody: Type<{ organizations: string[] }>(),
  },
🧹 Nitpick comments (3)
src/pages/Encounters/EncounterShow.tsx (2)

Line range hint 52-117: Remove commented-out code blocks.

Large blocks of commented code make the file harder to maintain and understand. If this code might be needed in the future, it's better tracked through version control. Consider:

  1. Removing all commented code blocks
  2. If some commented code represents pending work, replace with TODO comments referencing specific issue numbers

Also applies to: 171-196


Line range hint 143-151: Consolidate error checks.

The check for !encounterData is redundant as it's already handled in the loading condition above. Consider consolidating these checks:

- if (!props.tab) {
-   return <ErrorPage />;
- }
-
- if (!encounterData) {
-   return <ErrorPage />;
- }
+ if (!props.tab) {
+   return <ErrorPage />;
+ }
.eslintrc.json (1)

64-68: Consider establishing clear module boundaries with barrel exports.

While enforcing absolute imports, consider:

  1. Creating barrel exports (index.ts) for major feature modules
  2. Establishing a clear public API for each module
  3. Documenting the import convention in the project README

This will help maintain a clean architecture and make the codebase more maintainable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b52df97 and 8b38470.

📒 Files selected for processing (39)
  • .eslintrc.json (3 hunks)
  • src/App.tsx (1 hunks)
  • src/Routers/AppRouter.tsx (1 hunks)
  • src/Routers/PatientRouter.tsx (1 hunks)
  • src/Utils/request/useQuery.ts (1 hunks)
  • src/components/Common/Charts/ObservationChart.tsx (1 hunks)
  • src/components/Common/UserAutocompleteFormField.tsx (1 hunks)
  • src/components/Patient/PatientDetailsTab/index.tsx (1 hunks)
  • src/components/Patient/PatientInfoCard.tsx (1 hunks)
  • src/components/Patient/diagnosis/list.tsx (1 hunks)
  • src/components/Patient/symptoms/list.tsx (1 hunks)
  • src/components/Questionnaire/QuestionRenderer.tsx (1 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (1 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (1 hunks)
  • src/components/Questionnaire/QuestionnaireEditor.tsx (1 hunks)
  • src/components/Questionnaire/QuestionnaireForm.tsx (1 hunks)
  • src/components/Questionnaire/show.tsx (1 hunks)
  • src/components/Users/UserBanner.tsx (1 hunks)
  • src/pages/Encounters/EncounterShow.tsx (1 hunks)
  • src/pages/Facility/FacilitiesPage.tsx (1 hunks)
  • src/pages/Facility/FacilityDetailsPage.tsx (1 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (1 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx (1 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationView.tsx (1 hunks)
  • src/pages/Organization/OrganizationFacilities.tsx (1 hunks)
  • src/pages/Organization/OrganizationPatients.tsx (1 hunks)
  • src/pages/Organization/OrganizationUsers.tsx (1 hunks)
  • src/pages/Organization/OrganizationView.tsx (1 hunks)
  • src/pages/Patient/index.tsx (1 hunks)
  • src/pluginTypes.ts (1 hunks)
  • src/types/emr/allergyIntolerance/allergyIntoleranceApi.ts (1 hunks)
  • src/types/emr/diagnosis/diagnosisApi.ts (1 hunks)
  • src/types/emr/symptom/symptomApi.ts (1 hunks)
  • src/types/facility/facilityApi.ts (1 hunks)
  • src/types/organization/organizationApi.ts (1 hunks)
  • src/types/questionnaire/question.ts (1 hunks)
  • src/types/questionnaire/questionnaire.ts (1 hunks)
  • src/types/questionnaire/questionnaireApi.ts (1 hunks)
  • src/types/questionnaire/questionnaireResponse.ts (1 hunks)
✅ Files skipped from review due to trivial changes (26)
  • src/Utils/request/useQuery.ts
  • src/components/Patient/diagnosis/list.tsx
  • src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx
  • src/pages/Organization/OrganizationView.tsx
  • src/types/facility/facilityApi.ts
  • src/types/emr/allergyIntolerance/allergyIntoleranceApi.ts
  • src/types/questionnaire/question.ts
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx
  • src/pages/Organization/OrganizationUsers.tsx
  • src/pages/Organization/OrganizationPatients.tsx
  • src/components/Patient/PatientInfoCard.tsx
  • src/types/emr/symptom/symptomApi.ts
  • src/components/Users/UserBanner.tsx
  • src/pages/Organization/OrganizationFacilities.tsx
  • src/types/emr/diagnosis/diagnosisApi.ts
  • src/components/Common/UserAutocompleteFormField.tsx
  • src/Routers/PatientRouter.tsx
  • src/pages/Patient/index.tsx
  • src/components/Patient/symptoms/list.tsx
  • src/pages/FacilityOrganization/FacilityOrganizationView.tsx
  • src/pages/Facility/FacilityDetailsPage.tsx
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx
  • src/components/Questionnaire/QuestionRenderer.tsx
  • src/components/Questionnaire/QuestionnaireForm.tsx
  • src/types/questionnaire/questionnaire.ts
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/components/Common/Charts/ObservationChart.tsx
  • src/pages/Facility/FacilitiesPage.tsx
  • src/types/organization/organizationApi.ts
  • src/types/questionnaire/questionnaireResponse.ts
  • src/components/Questionnaire/show.tsx
  • src/components/Questionnaire/QuestionnaireEditor.tsx
🔇 Additional comments (13)
src/App.tsx (1)

20-20: LGTM! Import path updated correctly.

The change from relative to absolute import path aligns with the PR objective and maintains consistency with other imports in the file.

Let's verify the path alias configuration:

✅ Verification successful

Path alias configuration verified successfully

The @/ import path is properly configured in the TypeScript configuration, mapping @/* to ./src/*. The import statement follows the correct pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for path alias configuration in common config files

# Check for path alias in tsconfig.json
echo "Checking tsconfig.json for path aliases..."
fd -t f "tsconfig.*json" -x cat {} | jq -r '.compilerOptions.paths | select(. != null)'

# Check for path alias in vite.config.ts/js
echo "Checking vite config for path aliases..."
fd -t f "vite.config.(ts|js)" -x cat {}

Length of output: 433

src/pages/Encounters/EncounterShow.tsx (2)

19-19: LGTM! Import path follows the new convention.

The import statement correctly uses an absolute path with the @/ prefix, which aligns with the PR objective to disallow relative imports.


Line range hint 31-36: LGTM! EncounterNotesTab integration looks good.

The notes key in defaultTabs correctly references the imported EncounterNotesTab component, maintaining consistency with other tab components.

src/types/questionnaire/questionnaireApi.ts (2)

3-11: LGTM! Import paths successfully updated to absolute paths.

The changes align with the PR objective of transitioning from relative to absolute imports, maintaining consistent use of the '@/' prefix.


Line range hint 74-84: Verify API endpoint response types with backend.

Please ensure that both new endpoints' response types (PaginatedResponse<Organization>) match the backend implementation.

Run this script to check the API documentation or implementation:

src/components/Patient/PatientDetailsTab/index.tsx (2)

Line range hint 1-40: LGTM! The changes align with the PR objective.

The conversion from relative to absolute imports is consistent with the PR's goal to disallow relative imports. The component structure and tab configuration remain unchanged, maintaining the existing functionality.


3-8: Verify that all imported components exist at the specified paths.

The import paths have been updated to use absolute paths with the @/ prefix. Let's verify these components exist at the specified locations.

✅ Verification successful

All component imports are valid and correctly mapped to their source files.

The following components are properly exported from their respective files in the src/components/Patient/PatientDetailsTab directory:

  • Appointments from Appointments.tsx
  • Demography from Demography.tsx
  • PatientFilesTab from PatientFiles.tsx
  • PatientUsers from PatientUsers.tsx
  • ResourceRequests from ResourceRequests.tsx
  • Updates from patientUpdates.tsx
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all imported components exist at the specified paths

# Check if the component files exist
components=(
  "components/Patient/PatientDetailsTab/Appointments"
  "components/Patient/PatientDetailsTab/PatientFiles"
  "components/Patient/PatientDetailsTab/PatientUsers"
  "components/Patient/PatientDetailsTab/ResourceRequests"
)

for component in "${components[@]}"; do
  echo "Checking for $component..."
  fd -t f "^index\.(tsx?|jsx?)$|^[^/]+\.(tsx?|jsx?)$" "src/$component"
done

Length of output: 1954


Script:

#!/bin/bash
# Search for each component definition using ripgrep
components=("Appointments" "Demography" "PatientFilesTab" "PatientUsers" "ResourceRequests" "Updates")

for component in "${components[@]}"; do
  echo "=== Searching for component: $component ==="
  # Search for component definition
  rg -l --type ts --type tsx "export.*${component}.*" src/
  # Also search with type/interface definitions to catch potential issues
  rg -l --type ts --type tsx "type.*${component}.*|interface.*${component}.*" src/
done

# Additionally, let's verify the specific PatientDetailsTab directory structure
echo -e "\n=== Checking PatientDetailsTab directory ==="
fd . "src/components/Patient/PatientDetailsTab"

Length of output: 2810


Script:

#!/bin/bash
# Check the actual exports from the component files
files=(
  "src/components/Patient/PatientDetailsTab/PatientFiles.tsx"
  "src/components/Patient/PatientDetailsTab/patientUpdates.tsx"
)

for file in "${files[@]}"; do
  echo "=== Checking exports in $file ==="
  ast-grep --pattern 'export $_' "$file"
done

Length of output: 737


Script:

#!/bin/bash
# Check component exports with more specific patterns
files=(
  "Appointments.tsx"
  "Demography.tsx"
  "PatientFiles.tsx"
  "PatientUsers.tsx"
  "ResourceRequests.tsx"
  "patientUpdates.tsx"
)

for file in "${files[@]}"; do
  echo "=== Checking exports in $file ==="
  ast-grep --pattern 'export const $_ = $_' "src/components/Patient/PatientDetailsTab/$file"
  ast-grep --pattern 'export function $_($_) { $$$ }' "src/components/Patient/PatientDetailsTab/$file"
done

Length of output: 77802

.eslintrc.json (4)

22-23: LGTM! Appropriate MDX configuration.

The MDX file configuration is well-structured and follows recommended practices.


38-38: LGTM! Plugin addition aligns with PR objective.

The addition of the no-relative-import-paths plugin is necessary to support the new absolute import path requirements.


56-57: Review the permissive exclude patterns in i18next configuration.

The use of ".*" in exclude patterns effectively bypasses all i18next checks. This could lead to untranslated strings making their way into the application. Consider:

  1. Using more specific exclude patterns
  2. Removing the exclude patterns if they're not necessary

Let's verify the impact:

Also applies to: 60-60


64-68: Verify the impact of strict relative import restrictions.

While the rule configuration aligns with the objective, let's verify that this won't cause issues with:

  1. Test files that might benefit from relative imports
  2. Deeply nested component structures
  3. Package exports

Let's analyze the codebase structure:

✅ Verification successful

Consider adding allowance patterns for test files

The codebase structure is compatible with the strict relative import restriction, but consider:

  1. Adding allowPatterns to the rule config for test files (.test., .spec.) to maintain flexibility in testing
  2. Including a comment in the config explaining the '@' prefix choice for team reference

Example:

{
  "prefix": "@",
  "allowPatterns": ["**/*.test.*", "**/*.spec.*"]
}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential problematic import patterns
echo "Analyzing directory structure..."
find src -type d -mindepth 3 | sort -r | head -n 5

echo "Checking test file imports..."
rg -t tsx -t jsx "from '\.\." --glob "*.test.*" --glob "*.spec.*"

echo "Checking package exports..."
find src -name "index.ts" -o -name "index.tsx" | while read -r file; do
  echo "=== $file ==="
  rg "export .* from '\.\." "$file" || true
done

Length of output: 1840


Script:

#!/bin/bash
# Retry test file analysis with correct parameters
echo "Checking test file imports..."
rg "from '\.\." --type=typescript --type=javascriptreact --type=typescriptreact --glob "*.test.*" --glob "*.spec.*"

echo "Checking existing absolute import patterns..."
rg "from '@/" --type=typescript --type=javascriptreact --type=typescriptreact | head -n 5

Length of output: 455


Script:

#!/bin/bash
# Check imports using file extensions
echo "Checking test file imports..."
rg "from '\.\." --glob "*.ts" --glob "*.tsx" --glob "*.jsx" --glob "*.js" --glob "*.test.*" --glob "*.spec.*"

echo "Checking existing absolute import patterns..."
rg "from '@/" --glob "*.ts" --glob "*.tsx" --glob "*.jsx" --glob "*.js" | head -n 5

Length of output: 373

src/pluginTypes.ts (1)

4-4: LGTM! Verify path resolution for absolute imports.

The conversion from relative to absolute imports is correct and aligns with the standardization objective.

Let's verify that the import paths resolve correctly:

Also applies to: 7-7, 9-9

src/Routers/AppRouter.tsx (1)

18-18: Consider path structure consistency.

While the conversion to absolute imports is correct, the path structure has been made longer than necessary:

  • Current: @/Routers/routes/...
  • Could be: @/routes/...

This doesn't affect functionality but might impact maintainability if the directory structure changes.

Let's verify the path resolution and check for consistency across the codebase:

Also applies to: 23-23

src/components/Patient/PatientDetailsTab/index.tsx Outdated Show resolved Hide resolved
@rithviknishad rithviknishad removed the Deploy-Failed Deplyment is not showing preview label Jan 17, 2025
Copy link

👋 Hi, @AdityaJ2305,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Jan 20, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18572d9 and 553623e.

📒 Files selected for processing (2)
  • src/components/Patient/PatientRegistration.tsx (1 hunks)
  • src/pluginTypes.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Patient/PatientRegistration.tsx
🧰 Additional context used
🪛 GitHub Check: cypress-run (1)
src/pluginTypes.ts

[failure] 4-4:
Duplicate identifier 'QuestionnaireFormState'.


[failure] 7-7:
Duplicate identifier 'AppRoutes'.


[failure] 9-9:
Duplicate identifier 'pluginMap'.

🪛 GitHub Actions: Lint Code Base
src/pluginTypes.ts

[error] 13-13: Import statements should have an absolute path (no-relative-import-paths/no-relative-import-paths)

🪛 GitHub Actions: Cypress Tests
src/pluginTypes.ts

[error] 13-13: Import statements should have an absolute path

🪛 GitHub Actions: Deploy Care Fe
src/pluginTypes.ts

[error] 4-15: Multiple duplicate identifier errors found: 'QuestionnaireFormState', 'AppRoutes', and 'pluginMap' are declared multiple times

🔇 Additional comments (1)
src/pluginTypes.ts (1)

4-4: 💡 Codebase verification

Update imports in src/pluginTypes.ts to use absolute paths

The imports in src/pluginTypes.ts should be updated to use absolute paths with the @/ prefix to maintain consistency with the rest of the codebase:

  • "./Routers/AppRouter""@/Routers/AppRouter"
  • "./components/Questionnaire/QuestionnaireForm""@/components/Questionnaire/QuestionnaireForm"
  • "./pluginMap""@/pluginMap"
  • "./types/facility/facility""@/types/facility/facility"
🔗 Analysis chain

Verify absolute import paths across the codebase.

The transition to absolute imports using the @/ prefix looks good. Let's verify that these paths are consistent across the codebase.

Also applies to: 7-7, 9-9

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of absolute import paths

# Check if these modules are imported consistently across the codebase
echo "Checking import patterns for QuestionnaireFormState..."
rg "import.*QuestionnaireFormState.*from.*" -g "!src/pluginTypes.ts"

echo "Checking import patterns for AppRoutes..."
rg "import.*AppRoutes.*from.*" -g "!src/pluginTypes.ts"

echo "Checking import patterns for pluginMap..."
rg "import.*pluginMap.*from.*" -g "!src/pluginTypes.ts"

# Check for any remaining relative imports that need to be updated
echo "Checking for remaining relative imports..."
rg "from ['\"]\.\.?/" --type ts

Length of output: 2729

⛔ Skipped due to learnings
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9838
File: src/components/Questionnaire/QuestionnaireForm.tsx:100-105
Timestamp: 2025-01-14T05:04:43.093Z
Learning: The QuestionnaireForm component in care_fe uses raviger's useNavigationPrompt hook for handling navigation prompts, replacing a previous custom hook implementation.
🧰 Tools
🪛 GitHub Check: cypress-run (1)

[failure] 4-4:
Duplicate identifier 'QuestionnaireFormState'.

🪛 GitHub Actions: Deploy Care Fe

[error] 4-15: Multiple duplicate identifier errors found: 'QuestionnaireFormState', 'AppRoutes', and 'pluginMap' are declared multiple times

src/pluginTypes.ts Outdated Show resolved Hide resolved
vite.config.mts Outdated Show resolved Hide resolved
src/components/ui/chart.tsx Outdated Show resolved Hide resolved
src/Utils/types.ts Show resolved Hide resolved
src/Utils/request/types.ts Outdated Show resolved Hide resolved
src/Routers/AppRouter.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (2)
src/pages/PublicAppointments/PatientRegistration.tsx (2)

Line range hint 47-47: Convert relative import to absolute path.

As per the PR objective to disallow relative imports, update the import path to use an absolute path with the @/ prefix.

-import GovtOrganizationSelector from "../Organization/components/GovtOrganizationSelector";
+import GovtOrganizationSelector from "@/pages/Organization/components/GovtOrganizationSelector";
🧰 Tools
🪛 GitHub Check: cypress-run (1)

[failure] 36-36:
'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u


[failure] 36-36:
Cannot find module '@/pages/Organization/components/OrganizationSelector' or its corresponding type declarations.

🪛 GitHub Check: lint

[failure] 36-36:
'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 eslint

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)

🪛 GitHub Actions: Lint Code Base

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 GitHub Actions: Cypress Tests

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 GitHub Actions: Deploy Care Fe

[error] 36-36: Cannot find module '@/pages/Organization/components/OrganizationSelector' or its corresponding type declarations


[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u


Remove unused import and standardize import path

The implementation shows:

  1. OrganizationSelector import is unused and should be removed
  2. GovtOrganizationSelector is the correct component, but should use absolute import path
🔗 Analysis chain

Line range hint 36-47: Implementation is incomplete and inconsistent with PR objectives.

The changes appear to be in a transitional state:

  1. The AI summary indicates that GovtOrganizationSelector should be replaced with OrganizationSelector, but the replacement hasn't been completed.
  2. The PR objective to disallow relative imports is partially implemented, with some relative imports still remaining.

Please clarify:

  1. Which organization selector component should be used?
  2. Should all relative imports be converted to absolute paths?

Run this script to find any other relative imports that need to be converted:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find relative imports in TypeScript/JavaScript files
rg -g '*.{ts,tsx,js,jsx}' '^import .+ from "\.\.' .

Length of output: 902


Script:

#!/bin/bash
# Check usage of both organization selectors in the file
echo "=== Content of PatientRegistration.tsx ==="
cat src/pages/PublicAppointments/PatientRegistration.tsx

echo -e "\n=== Other files importing organization selectors ==="
rg -g '*.{ts,tsx}' "import .+(?:Govt)?OrganizationSelector"

Length of output: 17190

🧰 Tools
🪛 GitHub Check: cypress-run (1)

[failure] 36-36:
'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u


[failure] 36-36:
Cannot find module '@/pages/Organization/components/OrganizationSelector' or its corresponding type declarations.

🪛 GitHub Check: lint

[failure] 36-36:
'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 eslint

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)

🪛 GitHub Actions: Lint Code Base

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 GitHub Actions: Cypress Tests

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 GitHub Actions: Deploy Care Fe

[error] 36-36: Cannot find module '@/pages/Organization/components/OrganizationSelector' or its corresponding type declarations


[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 553623e and bb18675.

📒 Files selected for processing (11)
  • .eslintrc.json (3 hunks)
  • src/Routers/AppRouter.tsx (1 hunks)
  • src/components/Common/Charts/ObservationChart.tsx (1 hunks)
  • src/components/Patient/PatientRegistration.tsx (1 hunks)
  • src/components/Questionnaire/QuestionnaireEditor.tsx (1 hunks)
  • src/components/Questionnaire/show.tsx (1 hunks)
  • src/pages/Facility/FacilitiesPage.tsx (1 hunks)
  • src/pages/PublicAppointments/PatientRegistration.tsx (1 hunks)
  • src/types/organization/organizationApi.ts (1 hunks)
  • src/types/questionnaire/questionnaireApi.ts (1 hunks)
  • src/types/questionnaire/questionnaireResponse.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/types/organization/organizationApi.ts
  • src/Routers/AppRouter.tsx
  • src/types/questionnaire/questionnaireResponse.ts
  • src/components/Questionnaire/QuestionnaireEditor.tsx
  • src/components/Patient/PatientRegistration.tsx
  • .eslintrc.json
  • src/pages/Facility/FacilitiesPage.tsx
  • src/components/Common/Charts/ObservationChart.tsx
  • src/components/Questionnaire/show.tsx
  • src/types/questionnaire/questionnaireApi.ts
🧰 Additional context used
🪛 GitHub Check: cypress-run (1)
src/pages/PublicAppointments/PatientRegistration.tsx

[failure] 36-36:
'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u


[failure] 36-36:
Cannot find module '@/pages/Organization/components/OrganizationSelector' or its corresponding type declarations.

🪛 GitHub Check: lint
src/pages/PublicAppointments/PatientRegistration.tsx

[failure] 36-36:
'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 eslint
src/pages/PublicAppointments/PatientRegistration.tsx

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)

🪛 GitHub Actions: Lint Code Base
src/pages/PublicAppointments/PatientRegistration.tsx

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 GitHub Actions: Cypress Tests
src/pages/PublicAppointments/PatientRegistration.tsx

[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u

🪛 GitHub Actions: Deploy Care Fe
src/pages/PublicAppointments/PatientRegistration.tsx

[error] 36-36: Cannot find module '@/pages/Organization/components/OrganizationSelector' or its corresponding type declarations


[error] 36-36: 'OrganizationSelector' is defined but never used. Allowed unused vars must match /^_/u


[error] 47-47: Import statements should have an absolute path

src/pages/PublicAppointments/PatientRegistration.tsx Outdated Show resolved Hide resolved
@rithviknishad rithviknishad added needs review and removed changes required Deploy-Failed Deplyment is not showing preview merge conflict pull requests with merge conflict labels Jan 20, 2025
Copy link

👋 Hi, @AdityaJ2305,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 20, 2025
@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Jan 20, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56bafb2 and 7eae09e.

📒 Files selected for processing (3)
  • src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx (1 hunks)
  • src/components/Resource/ResourceCommentSection.tsx (1 hunks)
  • src/types/emr/encounter.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/Resource/ResourceCommentSection.tsx
  • src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
🧰 Additional context used
🪛 GitHub Check: cypress-run (1)
src/types/emr/encounter.ts

[failure] 2-2:
Duplicate identifier 'FacilityOrganization'.

🪛 GitHub Actions: Lint Code Base
src/types/emr/encounter.ts

[error] 5-5: import statements should have an absolute path (no-relative-import-paths/no-relative-import-paths)

🪛 GitHub Actions: Cypress Tests
src/types/emr/encounter.ts

[error] 5-5: Import statements should have an absolute path

🪛 GitHub Actions: Deploy Care Fe
src/types/emr/encounter.ts

[error] 2-5: Duplicate identifier 'FacilityOrganization' found in file


[error] 5-5: Import statements should have an absolute path

src/types/emr/encounter.ts Show resolved Hide resolved
src/types/emr/encounter.ts Outdated Show resolved Hide resolved
@rithviknishad rithviknishad removed Deploy-Failed Deplyment is not showing preview merge conflict pull requests with merge conflict labels Jan 20, 2025
Copy link
Member

@khavinshankar khavinshankar left a comment

Choose a reason for hiding this comment

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

LGTM

@khavinshankar khavinshankar merged commit 06575f2 into ohcnetwork:develop Jan 20, 2025
15 of 16 checks passed
Copy link

@AdityaJ2305 Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

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

Successfully merging this pull request may close these issues.

Add eslint rule to disallow relative imports
4 participants