refactor: replace deep relative imports with application aliases - #7656
refactor: replace deep relative imports with application aliases#7656diegolmello wants to merge 4 commits into
Conversation
Rewrite 4,107 deep module references in app code and stories while keeping all 3,454 existing sibling and single-parent references unchanged. Enforce the ../../** restriction in Oxlint, including its TypeScript override. Keep the root-level app-supportedversions.json as the shared source of truth. Add app/supportedversions.ts as a one-level re-export and use its alias in the consumer and both Jest mocks. Keep scripts/pinned-shortnames in place for the emoji generator; app/pinned-shortnames.ts re-exports that same module for the emoji data test. Neither root file is copied or moved. Validation: format/lint/typecheck, full Jest suite, deliberate restricted import rejection, iOS and Android Metro release bundles, AST preservation audit, and CI test-map validation. No deep relative references remain.
|
Important Review skippedToo many files! This PR contains 910 files, which is 610 over the limit of 300. To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (910)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Android Build Available Rocket.Chat 4.77.0.109589 Internal App Sharing: https://play.google.com/apps/test/RQQ8k09hlnQ/ahAO29uNRFHgRlV90Iolm15KKflO5_vYVDEuG_ts45eD2CyEyRUtybHpn-vK-x3lmUh3WxQ9q4TgkxZpVsGJoeSg7v |
|
iOS Build Available Rocket.Chat 4.77.0.109590 |
Proposed changes
Use
~/for imports that traverse two or more parent directories in application code and stories. TypeScript paths define the aliases; Babel and Jest derive their mappings from the same configuration. Keep sibling and single-parent imports relative, and reject new deep relative imports through Oxlint.Move the theme entry into
app/theme/index.tsxwhile preserving its public import path.Issue(s)
https://rocketchat.atlassian.net/browse/NATIVE-1533
How to test or reproduce
Run
pnpm format-lintandTZ=UTC pnpm test. Build Metro release bundles for iOS and Android. Verify alias imports retain platform-specific resolution and the.mock.tspreference underRUNNING_E2E_TESTS=true.Verified locally: 258 Jest suites, 2,347 tests and 416 snapshots passed; full release bundles passed on both platforms. Independent AST comparison verified all 4,107 rewrites and preserved all 3,454 sibling/single-parent references. CI test-map validation passed.
Add a temporary
../../import underapp/and confirm Oxlint rejects it. Alias paths must also remain visible toimport/no-cycle.Screenshots
No visual changes.
Types of changes
Checklist
Further comments
The migration is split into alias setup and import conversion commits. The RN 0.83 / Expo 55 integration in #7481 will need to account for the rewritten paths and the new lint rule when updating its branch.