Skip to content

chore: extend @metamask/utils configs from the monorepo root - #10180

Merged
cryptodev-2s merged 3 commits into
mainfrom
chore/utils-replace-configs
Sep 11, 2026
Merged

cryptodev-2s merged 3 commits into
mainfrom
chore/utils-replace-configs

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Fourth step of migrating @metamask/utils (PR#9 of Phase B in the migration process guide).

The package's config files were standalone. They now extend the monorepo's, matching the other packages:

  • tsconfig.json extends ../../tsconfig.packages.json
  • tsconfig.build.json extends ../../tsconfig.packages.build.json
  • tsconfig.lint.json extends ./tsconfig.json and ../../tsconfig.packages.lint.json, emitting into ./.tsc-lint-cache
  • jest.config.cjs is a deepmerge of ../../jest.config.packages.cjs, so deepmerge is added as a devDependency
  • typedoc.json matches the other packages, outputting to api-docs

Two things are deliberately preserved rather than inherited away:

The stricter compiler flags. This package sets exactOptionalPropertyTypes, forceConsistentCasingInFileNames, noErrorTruncation and noUncheckedIndexedAccess, none of which are in tsconfig.base.json. The sources were written against them, and noUncheckedIndexedAccess is load bearing: several functions branch on an index access being undefined. eth-json-rpc-provider sets the same four, so this follows existing practice.

The 100% coverage thresholds, which the package has met since before the migration.

No references are needed: none of this package's dependencies live in this repo.

Two details worth flagging for review. exclude replaces rather than extends, so tsconfig.build.json repeats the root's entries alongside its own. And tsconfig.lint.json excludes *.test-d.ts, because those belong to tsd and pulling them in drags in tsd's own types, which reference lib="esnext" and widen built in types like ReadonlySet beyond this package's target.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Config and build-tooling only; no runtime or library API changes, with intentional preservation of strict TS flags and coverage gates.

Overview
Aligns @metamask/utils tooling with the rest of the monorepo by inheriting shared configs instead of maintaining full copies locally.

TypeScript: tsconfig.json, tsconfig.build.json, and tsconfig.lint.json now extend ../../tsconfig.packages*.json, with package-specific include/exclude (shared types, build excludes for fixtures/mocks/test-d) and lint cache paths unchanged in spirit. The package still overrides stricter compiler flags (exactOptionalPropertyTypes, noUncheckedIndexedAccess, etc.) that the sources depend on.

Jest: jest.config.cjs shrinks to a deepmerge of ../../jest.config.packages.cjs, adding deepmerge as a devDependency. Overrides keep 100% global coverage thresholds and extra coveragePathIgnorePatterns for fixtures and *.test-d.ts.

Typedoc: output directory moves from docs to api-docs, with an explicit ./tsconfig.build.json path—matching other packages.

Reviewed by Cursor Bugbot for commit 7cffab6. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s added this pull request to stack #10183 September 10, 2026 18:32
@cryptodev-2s cryptodev-2s self-assigned this Sep 10, 2026
@cryptodev-2s
cryptodev-2s marked this pull request as ready for review September 10, 2026 20:44
@cryptodev-2s
cryptodev-2s deployed to default-branch September 10, 2026 20:44 — with GitHub Actions Active
@cryptodev-2s
cryptodev-2s force-pushed the chore/utils-replace-configs branch from 246bbbb to a9f4b12 Compare September 10, 2026 21:34
Comment thread merged-packages/utils/tsconfig.json Outdated
Comment on lines +4 to +9
/**
* These are stricter than the monorepo defaults and the sources were
* written against them, so they are set here rather than inherited away.
* `noUncheckedIndexedAccess` in particular is load bearing: several
* functions branch on an index access being `undefined`.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we don't need this comment? We aren't taking anything away that isn't already there.

Suggested change
/**
* These are stricter than the monorepo defaults and the sources were
* written against them, so they are set here rather than inherited away.
* `noUncheckedIndexedAccess` in particular is load bearing: several
* functions branch on an index access being `undefined`.
*/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed here 7cffab6

Comment thread merged-packages/utils/jest.config.cjs Outdated
Comment on lines 31 to 32
// Reduce the default test timeout from 5s to 2.5s
testTimeout: 2500,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we don't need this either? If we really want to, we can reduce the global default to 2.5s. But in the meantime I don't see why we need to make an exception for utils. It's rare IMO that we run into timeout issues in tests.

Suggested change
// Reduce the default test timeout from 5s to 2.5s
testTimeout: 2500,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed here 7cffab6

@cryptodev-2s
cryptodev-2s force-pushed the chore/utils-replace-configs branch from a9f4b12 to 682e9da Compare September 11, 2026 06:49
@cryptodev-2s
cryptodev-2s force-pushed the chore/utils-replace-configs branch from 682e9da to 7a7c472 Compare September 11, 2026 07:02
@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Sep 11, 2026
Base automatically changed from chore/utils-remove-root-files to main September 11, 2026 09:55
Merged via the queue into main with commit 2a15362 Sep 11, 2026
335 checks passed
@cryptodev-2s
cryptodev-2s deleted the chore/utils-replace-configs branch September 11, 2026 09:58
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Sep 11, 2026
…taMask#10181)

## Explanation

Fifth step of migrating `@metamask/utils` (PR#10 of Phase B in the
[migration process
guide](https://github.com/MetaMask/core/blob/main/docs/processes/package-migration-process-guide.md)).

**Scripts** now match the other packages: `build:all`,
`changelog:update`, `changelog:validate`, `lint:tsconfigs`,
`since-latest-release`, and the `NODE_OPTIONS=--experimental-vm-modules`
test variants. The lint scripts (`lint`, `lint:eslint`,
`lint:constraints`, `lint:misc`, `lint:dependencies`, `lint:tsc`) are
gone because the root owns linting, and `prepack` is gone with the
`scripts/` directory removed in MetaMask#10179.

`test` keeps running `test:types` after Jest, since this package has
`tsd` type tests that nothing else would run.

**Dependencies**: 21 devDependencies drop to 17. Removed are the ones
the root already provides and no package declares for itself: the
`@lavamoat/*`, `@metamask/eslint-config*` and `eslint*` sets, plus
`@types/node`, `@types/semver`, `knip`, `oxfmt`, `prettier` and
`typescript-eslint`. Every one was already at a version identical to the
root's, so nothing changes on disk.

`jest-it-up` is also removed: it existed only to bump coverage
thresholds from the old `test:source` script, which no longer exists.

Kept, matching the convention in all 99 packages: `typescript`,
`@typescript/native`, `deepmerge`, `jest`, `ts-jest`, `rimraf`,
`typedoc`, `@metamask/auto-changelog`, `@types/jest`, and `tsx` for the
new `lint:tsconfigs` script. Kept as genuinely package specific:
`jest-when`, `@types/jest-when`, `@types/uuid`, `stdio-mock`, `tsd` and
`web3`. I verified each of those is actually imported by the sources.

`packageManager` is dropped because no package declares it (the root
does). `engines` stays, as it does in all 99. The `lavamoat` block
stays: 8 packages have one, including the same `unrs-resolver` entry.

Runtime dependencies are untouched.

## References

- Follows MetaMask#10180

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Package metadata and tooling only; runtime dependencies and library
code are untouched.
> 
> **Overview**
> Aligns **`@metamask/utils`** `package.json` with the rest of the
monorepo as part of the utils migration—**no runtime dependency
changes**.
> 
> **Scripts** now follow the shared pattern: `build:all`, root
`changelog:*`, `lint:tsconfigs`, `since-latest-release`, and Jest runs
with `NODE_OPTIONS=--experimental-vm-modules` plus `test:clean` /
`test:verbose`. Package-local **lint**, **prepack**, and **`test:source`
+ `jest-it-up`** are removed so the root owns linting and coverage
bumping. **`test`** still chains **`test:types`** (`tsd`) after Jest.
> 
> **DevDependencies** drop duplicate tooling the root already provides
(ESLint/LavaMoat stacks, `knip`, `oxfmt`, `prettier`, etc.) and add
**`tsx`** (for tsconfig lint) and **`typedoc-plugin-missing-exports`**.
**`packageManager`** is removed (declared at the root); **`engines`**
and **`lavamoat`** stay unchanged.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6489dce. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Sep 11, 2026
## Explanation

Phase C of migrating `@metamask/utils`, following [the package migration
process
guide](https://github.com/MetaMask/core/blob/main/docs/processes/package-migration-process-guide.md).
This moves the package from `merged-packages/` into `packages/` and
wires it into the monorepo.

- `merged-packages/utils` → `packages/utils`, registered as a workspace
- Reference paths added to the root `tsconfig.json`,
`tsconfig.build.json` and `tsconfig.lint.json`
- The version bump for dependents is split into a follow up (MetaMask#10192) to
keep this diff reviewable. This PR adds a temporary `@metamask/utils`
entry to `ALLOWED_INCONSISTENT_DEPENDENCIES` in `yarn.config.cjs` so
constraints pass while dependents are still on the published version;
MetaMask#10192 removes it. The two are meant to land together.
- Downstream tsconfig references added via `yarn lint:tsconfigs:fix:all`
(174 files). Without them `yarn lint:tsc` reported 536 errors; it is now
clean
- `yarn constraints --fix` applied, which split the test scripts into
`test:unit` and `test:types`
- CODEOWNERS entry added through `codeowners.ts` and `teams.json`,
assigning the package to `@MetaMask/core-platform` as with the other
foundational packages
- README package list and dependency graph regenerated with `yarn
readme-content:update`

### Type tests moved from `tsd` to `tstyche`

The package's type tests import from source (`./index.js`, `./misc.js`),
so they never needed built declarations. `tsd` requires a typings file
as a structural precondition regardless, which forced a build purely to
satisfy the tool. `tstyche` type checks source directly and is already
used by `@metamask/messenger`, so the four `*.test-d.ts` files are now
`*.tst.ts`, with all 120 assertions preserved.

That removed three workarounds: a `composite: false` override for `tsd`,
a `--typings` flag, and the `*.test-d.ts` exclusion in
`tsconfig.lint.json`. That last one existed because `tsd`'s own types
pull in `lib="esnext"`, widening built in types like `ReadonlySet` past
this package's target. With that gone the type tests are covered by
`lint:tsc` rather than excluded from it, and `tsd` leaves the lockfile
entirely.

### Root tooling now resolves the package from source

Nine files at the repository root import `@metamask/utils`, which
previously arrived prebuilt from npm. As a workspace its `dist` does not
exist until something builds it, and the lint jobs do not build, so
`constraints`, `lint:teams` and `lint:tsconfigs:all` all failed on a
fresh checkout.

Adding a `paths` entry to the root `tsconfig.json` fixes the scripts.
`yarn.config.cjs` is the exception, since Yarn loads it as plain
CommonJS where `paths` do not apply and a `.ts` file cannot be required.
It only used `hasProperty`, whose runtime body is a single expression,
so it now calls `Object.hasOwn` directly. That is available on every
supported Node version.

All of the following pass with no build artifacts present:
`constraints`, `lint:teams`, `lint:tsconfigs:all`,
`readme-content:check`, `codeowners:check`, `lint:tsc`,
`lint:misc:check`, and the package's own tests.

### Inherited lint findings

86 pre-existing findings in the package, mostly `no-explicit-any` in
tests, are recorded in `eslint-suppressions.json` rather than fixed
here, matching how this repo tracks that debt. They came from rules the
package's own ESLint config had disabled before the migration.

## References

- Follows MetaMask#10175, MetaMask#10178, MetaMask#10179, MetaMask#10180, MetaMask#10181 and MetaMask#10182
- Migration process guide:
`docs/processes/package-migration-process-guide.md`

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Wide monorepo integration touches build graphs and resolution for a
foundational dependency; temporary dual resolution (workspace v12 vs
published v11) must land with the follow-up bump to avoid inconsistent
runtime/types.
> 
> **Overview**
> **`@metamask/utils` is now a workspace package at `packages/utils`
(v12.0.0)** instead of living under `merged-packages/` or npm-only. Repo
metadata, CODEOWNERS/`teams.json`, README list/graph, and root
`tsconfig` project references are updated so the package builds and
lints with the rest of core.
> 
> **Monorepo wiring:** Jest and root/script `tsconfig` paths resolve
`@metamask/utils` (and `/node`) to **TypeScript source** so tests and
lint work without a prior build. Package `tsconfig` references to
`../utils` were added across dependents. **`tsconfig.packages.json`
still maps `@metamask/utils` to published v11 in `node_modules`** until
a follow-up bumps dependents; `yarn.config.cjs` temporarily allows that
version skew and drops the `@metamask/utils` import in favor of
**`Object.hasOwn`**.
> 
> **Package tooling:** Type tests move from **`tsd` (`*.test-d.ts`) to
`tstyche` (`*.tst.ts`)**; build excludes `*.tst.ts`. Unused
**`@metamask/utils` dependencies are removed** from a few packages (e.g.
messenger, ai-controllers). Pre-existing ESLint issues in
`packages/utils` are **recorded in `eslint-suppressions.json`**. Stale
**`merged-packages/utils`** type-test and lint config files are removed.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
dd04556. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants