[pull] main from MetaMask:main#724
Merged
Merged
Conversation
## **Description**
Follow-up to the BigInt introduction PR (which adds
`app/util/number/bigint.ts` and marks the helpers in
`app/util/number/index.js` as `@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 legacy `app/util/number`
importers can only go down from here.
**What this PR adds**
1. **`@typescript-eslint/no-deprecated: 'warn'`** in `.eslintrc.js` for
all `*.{ts,tsx}` files. Surfaces a warning at every use-site of any
helper already annotated `@deprecated` (the `app/util/number` exports
today, plus anything else marked deprecated in the future).
2. **`no-restricted-imports` fence** on `app/util/number` /
`app/util/number/index` for `app/**/*.{ts,tsx,js,jsx}`. New imports are
a **hard error** pointing the developer at `app/util/number/bigint`.
Existing importers (107 files at the
time of writing) live in a top-level `utilNumberImportBurndownFiles`
constant in `.eslintrc.js`. Entries should be **removed** as files are
migrated, never added. Two override blocks are needed because ESLint's
`excludedFiles` applies to the whole override, not per-rule. A single
combined block would silently exempt the burn-down files from the
existing `expo-haptics` and `**/controllers/perps` fences too. The first
override holds all three fences and excludes the burn-down list; the
second override re-applies only `expo-haptics` and perps to the
burn-down files.
3. **`app/util/number/**` is also excluded** so the legacy module and
its parity tests can keep importing each other for migration parity
comparisons.
4. **CODEOWNERS** entry: `app/util/number/index.js` is 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.ts` and the tests are not gated.
5. **Deletion of `calcTokenValueToSend`** from
`app/util/number/index.js` (and its test). The function was dead code
(only referenced by its own test).
**Why all three layers?**
| Layer | Catches |
| -------------------------------- |
----------------------------------------------------------------- |
| `@typescript-eslint/no-deprecated` (warn) | Every existing call-site
of a deprecated helper, even within the allowlist. |
| `no-restricted-imports` (error) | Any **new** file that tries to
import from the deprecated module. |
| CODEOWNERS | Any change to the deprecated module itself (new exports,
edits). |
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**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry:null
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
<!--
Every checklist item must be consciously assessed before marking this PR
as
"Ready for review". A checked box means you deliberately considered that
responsibility, not that you literally performed every action listed.
Unchecked boxes are ambiguous: they are not an implicit "N/A" and they
are not
a silent "skip". See `docs/readme/ready-for-review.md` for the full
checklist
semantics.
-->
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [ ] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **Pre-merge reviewer checklist**
<!--
Reviewer checklist items follow the same semantics as the author
checklist: an
unchecked box is ambiguous, a checked box means the reviewer consciously
assessed that responsibility. See `docs/readme/ready-for-review.md`.
-->
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!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 deprecated
`app/util/number/index.js`, with a temporary allowlisted burndown set.
>
> Updates `CODEOWNERS` to require platform review for changes to the
deprecated `app/util/number/index.js`, expands documentation with a
burndown-by-team section, and links the migration guide from the main
`README`.
>
> Removes the unused `calcTokenValueToSend` helper (and its test) from
the legacy number module, and increases Node memory limits for
`lint`/`tsc` scripts to reduce OOMs.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f2197ad. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cal-L <cal.leung@consensys.net>
Co-authored-by: tommasini <tommasini15@gmail.com>
Co-authored-by: tommasini <46944231+tommasini@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )