chore: fence off legacy BN.js helpers with lint + CODEOWNERS#29386
Conversation
…etaMask/metamask-mobile into feat/MCWP-370-introduce-native-big-int
…etaMask/metamask-mobile into feat/MCWP-370-introduce-native-big-int
Made-with: Cursor
…mobile into wsun/introduce-bigint
…ub.com:MetaMask/metamask-mobile into wsun/introduce-lint-rules-for-bigint-migration
…ub.com:MetaMask/metamask-mobile into wsun/introduce-lint-rules-for-bigint-migration
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 683dd65. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
No E2E tests are needed because:
Performance Test Selection: |
|




Description
Follow-up to the BigInt introduction PR (which adds
app/util/number/bigint.tsand marks the helpers inapp/util/number/index.jsas@deprecated). That PR provides the replacement API; this PR puts the guardrails in place so the migration becomes a one-way ratchet — the count of legacyapp/util/numberimporters can only go down from here.What this PR adds
@typescript-eslint/no-deprecated: 'warn'in.eslintrc.jsfor all*.{ts,tsx}files. Surfaces a warning at every use-site of any helper already annotated@deprecated(theapp/util/numberexports today, plus anything else marked deprecated in the future).no-restricted-importsfence onapp/util/number/app/util/number/indexforapp/**/*.{ts,tsx,js,jsx}. New imports are a hard error pointing the developer atapp/util/number/bigint. Existing importers (107 files at thetime of writing) live in a top-level
utilNumberImportBurndownFilesconstant in.eslintrc.js. Entries should be removed as files are migrated, never added. Two override blocks are needed because ESLint'sexcludedFilesapplies to the whole override, not per-rule. A single combined block would silently exempt the burn-down files from the existingexpo-hapticsand**/controllers/perpsfences too. The first override holds all three fences and excludes the burn-down list; the second override re-applies onlyexpo-hapticsand perps to the burn-down files.app/util/number/**is also excluded so the legacy module and its parity tests can keep importing each other for migration parity comparisons.CODEOWNERS entry:
app/util/number/index.jsis now owned by@MetaMask/mobile-platform. Any change to the deprecated module (e.g. adding a new export, modifying an existing helper) requires platform review. Scope is intentionally limited to the deprecated file —bigint.tsand the tests are not gated.Deletion of
calcTokenValueToSendfromapp/util/number/index.js(and its test). The function was dead code (only referenced by its own test).Why all three layers?
@typescript-eslint/no-deprecated(warn)no-restricted-imports(error)The combination gives a one-way ratchet: warnings flag what to migrate,
the import fence prevents new debt, and CODEOWNERS prevents the legacy
module from quietly growing.
Changelog
CHANGELOG entry:null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Primarily tooling/guardrail changes, but new ESLint fences and deprecated-use warnings can break builds for newly added/modified imports and may require follow-up fixes across many files as migration progresses.
Overview
Adds migration guardrails for the BN.js → BigInt transition by enabling
@typescript-eslint/no-deprecated(warn) and introducing an ESLint import fence that blocks new imports resolving to deprecatedapp/util/number/index.js, with a temporary allowlisted burndown set.Updates
CODEOWNERSto require platform review for changes to the deprecatedapp/util/number/index.js, expands documentation with a burndown-by-team section, and links the migration guide from the mainREADME.Removes the unused
calcTokenValueToSendhelper (and its test) from the legacy number module, and increases Node memory limits forlint/tscscripts to reduce OOMs.Reviewed by Cursor Bugbot for commit f2197ad. Bugbot is set up for automated code reviews on this repo. Configure here.