Skip to content

Fix import/no-cycle that are currently silent #99650

Open

Description

@LukasMod

Background

While preparing the ESLint to Oxlint migration, a batch of violations surfaced that ESLint does not report
today. import/no-cycle is the largest of them by a wide margin: 534 circular imports across 148 files
in src/
, all of them real.

The rule has been in our ESLint config for years with maxDepth: '∞', and it reports 0. ESLint's
resolver never resolves the @src/..., @libs/... and @components/... aliases, so it never builds a
module graph and has nothing to check. Oxlint reads tsconfig.json, resolves the aliases, and sees the
graph.

Fixing what the new linter found is a prerequisite for the migration. The day Oxlint becomes a blocking
check, these 534 findings become 534 hard errors, so the cleanup has to land first and on its own schedule.

Cycle path is a symptom, not a work item. Break the cycle it draws and the finding often
survives, now drawing a different cycle through the same import. One row fixed can reappear as another cycle issue re-reported.

The numbers

Findings 534
Files involved 148, all under src/
Mutually dependent clusters 6, largest 116 files
Import edges inside those clusters 537
Import edges that must break to reach 0 findings 54
Shortest and longest cycle 2 and 39 modules

Definition of done

  • A clean Oxlint run reports 0 import/no-cycle findings.
  • No eslint-disable or oxlint-disable comment is added for import/no-cycle anywhere. A suppressed cycle
      is still a cycle and still carries costs.

How to validate numbers

List generated on POC oxlint branch #98027
To reproduce use .oxlintrc.no-cycle.json and run command:

npx oxlint . -c .oxlintrc.no-cycle.json -f json > oxlint-no-cycle-findings.json

Current results:
oxlint-no-cycle-findings.json

Issue OwnerCurrent Issue Owner: @thelullabyy

Activity

  1. LukasMod commented on Aug 27, 2026

    @LukasMod
    ContributorAuthor
  2. MelvinBot commented on Aug 27, 2026

    @MelvinBot
    Contributor

    🤖 Done — assigned roryabraham and LukasMod to this issue.


    view run

  3. LukasMod commented on Aug 28, 2026

    @LukasMod
    ContributorAuthor

    1 PR: #99670 is ready for review: 534 findings reduced to 478 (-56)

  4. added
    Reviewing
    Weekly
    on Aug 28, 2026
  5. thelullabyy commented on Aug 30, 2026

    @thelullabyy
    Contributor

    @roryabraham @LukasMod Since I reviewed the first PR, could you please assign me the assign so that I will be assigned on the part 2 PR?

  6. LukasMod commented on Aug 31, 2026

    @LukasMod
    ContributorAuthor

    @thelullabyy Sorry but I don't have such permissions to assign someone. Lets wait for @roryabraham to decide that.
    In a meantime I prepared PR2: #99768 478 -> 458 (-20)

  7. roryabraham commented on Aug 31, 2026

    @roryabraham
    Contributor

    PR 1 merged. Requested @thelullabyy review on parts 2 and 3

  8. removed
    Reviewing
    on Aug 31, 2026
  9. added
    Reviewing
    and removed
    Reviewing
    Weekly
    on Sep 1, 2026
  10. 122 remaining items

  11. melvin-bot commented on Nov 9, 2026

    @melvin-bot

    @thelullabyy Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. roryabraham commented on Nov 9, 2026

    @roryabraham
    Contributor

    @MelvinBot inventory what we have left to do here

  13. MelvinBot commented on Nov 9, 2026

    @MelvinBot
    Contributor

    Remaining inventory

    The review queue is clear: parts 1–22 are merged. Part 22 merged today. I found no PRs for parts 23–25.

    Current main’s seatbelt records 32 import/no-cycle findings across 14 files:

    Area Findings
    TransactionUtils — index, duplicates, getUpdatedTransaction, tax, violations 12
    PolicyUtils — approvals, index, members, tag 7
    ReportActionsUtils, ReportNameUtils, ReportUtils 9
    ViolationsUtils 3
    BankAccounts 1

    These are baseline allowances, not a fresh lint measurement or 32 independent fixes.

    Work left

    • Re-run the cycle analysis now that part 22 has merged. Refresh the actual findings and dependency clusters before sizing the next batch.
    • Revalidate and implement the remaining planned parts 23–25:
      • 23: Extract pressLockedBankAccount from BankAccounts; pass bank-account data explicitly.
      • 24: Remove ReportUtils’ dependency on ViolationsUtils.
      • 25: Extract a TransactionUtils core leaf and pass transaction data into approvals instead of relying on its cache.
    • Scope the final interconnected tail around ReportActionsUtils, ReportUtils and TransactionUtils. The earlier “~13 left” projection is stale—not a verified current remainder.
    • Validate completion: zero raw cycle findings, tighten the seatbelt to zero for this rule, and ensure fixes introduce no cycle-disable comments.
    • Finish release/regression checks and consolidated payment closeout. Skip Payment remains set per the consolidation decision.

    Already done: Oxlint is now the blocking linter through the migration PR, so adding the guardrail is no longer outstanding. The immediate next action is the post-part-22 analysis, not another review round.


    view run

  14. LukasMod commented on Nov 10, 2026

    @LukasMod
    ContributorAuthor

    I'm working on an updated plan based on the current repo state, as some things have already changed. At the moment, we have 39 issues left (32 if we exclude the ones with eslint-disable).

    Also, I'll be OOO on November 11 due to a national public holiday.

    PR Description Removes Count after (stacked) Size Kind Depends on
    1 Move pure TransactionUtils helpers into leaf files 12 39 → 27 11 files, +262/-191 Mechanical none
    2 Pass bankAccountList instead of importing the BankAccounts action 5 27 → 22 10 files, +83/-36 Logic (data passed in) none
    3 Approvals take reportTransactions instead of importing TransactionUtils 7 22 → 15 14 files, +133/-56 Logic (data passed in) PR 1
    4 Stop re-exporting duplicate helpers from the TransactionUtils barrel 2 15 → 13 16 files, +86/-95 Mechanical PR 1
    5 Take TransactionUtils/violations.ts out of the loop 3 10 → 7 13 files, +192/-142 Mostly mechanical PR 1
    6 ReportActionsUtils stops importing ReportUtils 3 13 → 10 11 files, +66/-27 Logic none
    7 ReportUtils stops importing ViolationsUtils 3 7 → 4 14 files, +440/-405 Move + function passed in PR 1
    8 ReportUtils stops importing ReportNameUtils 2 4 → 2 21 files, +487/-92 Logic, function passed in none
    9 TransactionUtils/index stops importing ReportUtils 2 2 → 0 not built yet Logic PR 1 to 8

    PR details

    PR 1: TransactionUtils leaf helpers (-12)
    • Summary: move pure helpers out of TransactionUtils/index.ts into leaf files that import nothing from the loop, and point the sub-files at them instead of ./index.
    • Change:
      • New TransactionUtils/tagArray.ts (getTagArrayFromName), used by PolicyUtils/tag.ts and buildOptimisticTransaction.ts.
      • Pure getters (getAmount, getCurrency, getMerchant, getTag, getCategory, isScanRequest, ...) moved into TransactionUtils/fields.ts; index.ts re-exports them, so outside callers do not change.
      • New ReportStateUtils.ts with isOpenReport / isProcessingReport (stateNum/statusNum checks); ReportUtils imports and re-exports them.
      • tax.ts, duplicates.ts, getUpdatedTransaction.ts and ReportNameUtils.ts import from the leaves and from PolicyUtils sub-files instead of the barrels. Obsolete disable comments removed.
    • Kind: mechanical. No signature changes.
    • Review: minor. Keep a justification on the one eslint-disable that stays in TransactionUtils/index.ts until PR 4, and tidy two comments in fields.ts.
    PR 2: bank account list as a parameter (-5)
    • Summary: PolicyUtils/members.ts and ReportUtils.getReportPreviewMessage read the bank account from a bankAccountList parameter instead of getBankAccountFromID in actions/BankAccounts.
    • Change:
      • getEligibleBankAccountShareRecipientEmails / hasEligibleBankAccountShareRecipient take bankAccountList; ShareBankAccount.tsx and WalletPage pass useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST).
      • getReportPreviewMessage reads bankAccountList?.[bankAccountID]. To keep every path correct, bankAccountList is also threaded through OptionsListUtils (GetAlternateTextConfig, getSearchOptions, getValidOptions) from SearchAutocompleteList, useAutocompleteSuggestions and useSearchSelector/base (one new useOnyx there).
    • Kind: logic (data flow). Behavior is unchanged for the invoice-paid preview. Side effect: the neighbouring business-bank-account preview branch, which already read bankAccountList and got undefined on the Search path, now gets the real list too.
    • Review: minor. Optionally add a selector to the useOnyx in ShareBankAccount.tsx.
    PR 3: approvals take report transactions (-7, needs PR 1)
    • Summary: PolicyUtils/approvals.ts stops calling getAllSortedTransactions(reportID); getRuleApprovers, getFirstRuleApprover, getSubmitToEmail, getSubmitToAccountID and getSubmitReportManagerAccountID take reportTransactions.
    • Change: about 35 call sites in ReportUtils, OptionsListUtils, Report{Primary,Secondary,Preview}ActionUtils, SearchUIUtils, actions/Report, actions/Search, ReportWorkflow, useReportSubmitToPopover, plus PolicyUtilsTest and the perf-local test.
    • Kind: logic (data flow).
    • Review: must fix before opening.
      • SearchUIUtils passes only the row's transaction (or Search snapshot transactions), so a rule approver tied to another expense on the report can be missed, which can change whether APPROVE shows.
      • Header callers pass nonPendingDeleteTransactions, which changes which expenses pick the approver.
      • PERF-2: callers now look up and sort transactions even when the policy has no approval rules, and the list is sorted twice. Pass the unsorted list, or keep the lookup lazy.
      • Fix direction: every caller passes exactly the set the old internal lookup used.
    PR 4: duplicates no longer re-exported from the barrel (-2, needs PR 1)
    • Summary: TransactionUtils/index.ts stops re-exporting the 6 duplicate-expense helpers; consumers import from @libs/TransactionUtils/duplicates.
    • Change: 12 source files (7 DynamicReview*Page, DynamicConfirmationPage, MoneyRequestHeaderPrimaryAction, TransactionPreview, TransactionPreviewUtils, IOU actions) and 2 test files. This also clears duplicates.ts -> ReportUtils.
    • Kind: mechanical (import paths only).
    • Review: clean.
    PR 5: TransactionUtils/violations.ts out of the loop (-3, needs PR 1)
    • Summary: violations.ts imports only from fields.ts and ReportStateUtils.ts.
    • Change:
      • Pure predicates isIOUReport, isInvoiceReport, isOpenExpenseReport, isSettled, isCurrentUserSubmitter and isReportManager move to ReportStateUtils.ts. ReportUtils keeps same-name wrappers, so its roughly 100 importers do not change.
      • isCategoryBeingAnalyzed / isMerchantMissing move to fields.ts; hasPendingUI / isTransactionSubmittable move to index.ts.
      • shouldShowBrokenConnectionViolation takes currentUserAccountID; its 5 component callers and ReportPrimaryActionUtils already have the value.
    • Kind: mostly mechanical, one new parameter.
    • Review: minor. Fix the fields.ts header comment and type currentUserAccountID as number.
    PR 6: ReportActionsUtils stops importing ReportUtils (-3)
    • Summary: removes the only runtime import from ReportActionsUtils into ReportUtils, which takes ReportActionsUtils out of the loop.
    • Change:
      • New leaf doesReportContainRequestsFromMultipleUsers.ts. hasRequestFromCurrentAccount takes reportTransactions; its 7 callers pass it (4 add useReportTransactions).
      • The support-ticket check in isReportActionVisible reads a report-ID set that Parser.ts builds inside its existing Onyx.connect callback. No new subscription.
    • Kind: logic.
    • Review: minor.
      • The old check also looked at draft reports; support tickets are never written as drafts, so nothing changes in practice. Say so in the PR body.
      • SettlementButton adds a useReportTransactions per Search row (a perf note, not a rule violation).
    • Open: is Parser.ts an acceptable home for the support-ticket set?
    PR 7: ReportUtils stops importing ViolationsUtils (-3, needs PR 1)
    • Summary: moves the two policy-violation builders out of ReportUtils and passes hasVisibleViolationsForUser in where ReportUtils needs it.
    • Change:
      • pushTransactionViolationsOnyxData, pushTransactionAutoSelectionsOnyxData and their helpers move verbatim to a new src/libs/Violations/policyViolationUpdates.ts; 12 call sites repointed.
      • getViolatingReportIDForRBRInLHN, hasReportErrorsOtherThanFailedReceipt and generateReportAttributes take hasVisibleViolationsForUser as a required callback; 6 production callers pass the real function.
    • Kind: a large verbatim move, plus a function passed as a parameter.
    • Review: minor (comment style). Design concern: the callback exists only to break the import.
    PR 8: ReportUtils stops importing ReportNameUtils (-2)
    • Summary: moves getReportName to a leaf and passes the three name generators in as parameters.
    • Change:
      • New src/libs/getReportName.ts; ReportNameUtils re-exports it, so its roughly 45 callers do not change.
      • getIcons (via GetIconsParams) takes getGroupChatName; getParentNavigationSubtitle takes getInvoicePayerName; getChatListItemReportName takes getInvoiceReportName. 12 production and about 40 test call sites updated.
    • Kind: logic, functions passed as parameters.
    • Review: minor. Move the JSDoc in getReportName.ts back above the function, and say the "injected to avoid the cycle" comment once instead of 4 times. Same design concern as PR 7.
    • Alternative: move getIcons and friends out of ReportUtils into their own module. That avoids callbacks but repoints every importer of getIcons (a re-export from ReportUtils would bring the loop back).
    PR 9: TransactionUtils/index stops importing ReportUtils (-2, last)
    • Summary: after PR 1 to 8, the only loop left is ReportUtils <-> TransactionUtils/index.ts. ReportUtils -> TransactionUtils has hundreds of uses and cannot be cut, so TransactionUtils must drop its 5 ReportUtils imports.
    • Plan:
      • isThread, isIOUReport: use leaf versions in ReportStateUtils.ts (isIOUReport arrives with PR 5).
      • getReportTransactions, getReportOrDraftReport (read Onyx-backed state in ReportUtils): pass the data in from callers.
      • getTransactionDetails: move it out of ReportUtils if its dependencies allow, otherwise pass in what it reads.
    • Status: not built. A first prototype timed out halfway; a second run is in progress.
  15. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    @thelullabyy

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.5.35-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

  16. LukasMod commented on Nov 12, 2026

    @LukasMod
    ContributorAuthor

    Part 23 is ready: #106716

    It covers PR 1 and PR 4 from the plan, so it brings the count from 39 to 25. I left out the ReportStateUtils.ts leaf from PR 1 because the count is 25 without it. It can come back with PR 5 or 9 where violations.ts actually needs it.

  17. added
    Reviewing
    Weekly
    and removed
    Daily
    on Nov 12, 2026
  18. LukasMod commented on Nov 23, 2026

    @LukasMod
    ContributorAuthor

    Part 24 is ready: #107381
    It covers PR 5 from the plan

  19. LukasMod commented on Nov 27, 2026

    @LukasMod
    ContributorAuthor

    Update, 2 waiting for review:
    Part 24: #107381
    Part 25 (new one): #108190 (covers PR 2 from the plan)

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

Metadata

Metadata

Labels

ReviewingSkip PaymentWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions