chore: migrate ESLint to v9 flat config#134
Conversation
Replace .eslintrc.js with eslint.config.mjs using the @metamask/eslint-
config* v15 family (flat config + ESLint 9). Cascading bumps: prettier
2 -> 3 (peer dep), drop @typescript-eslint/{eslint-plugin,parser}
(replaced by typescript-eslint metapackage), add eslint-plugin-import-x,
eslint-plugin-jsdoc, eslint-plugin-n, eslint-plugin-promise,
eslint-import-resolver-typescript.
Split tsconfig into tsconfig.json (no-emit, includes test files for
type-aware lint) and tsconfig.build.json (emit lib/ for ncc, excludes
tests). Bump engines.node from >=14 to "^20 || ^22 || >=24" -- already
true in practice via Yarn 4 + Corepack + .nvmrc lts/*, and the n
plugin enforces it.
Source fixes for new rules: switch to node: prefix imports, drop
unused catch binding, convert interface->type where the augmentation
pattern doesn't require interface.
Disable a few rules that don't fit this repo: jsdoc/require-* (this
codebase doesn't JSDoc internals), import-x/no-nodejs-modules (it's
a Node Action), explicit-function-return-type, and allow UPPER_CASE
type properties for env-var-shaped types.
dist/index.js regenerates with minor structural differences after the
lockfile churn; source unchanged.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning MetaMask internal reviewing guidelines:
Ignoring alerts on:
|
|
@SocketSecurity ignore npm/@typescript-eslint/eslint-plugin@8.61.0 These look fine. @SocketSecurity ignore npm/@tybys/wasm-util@0.10.2 Network access ok. @SocketSecurity ignore npm/unrs-resolver@1.12.2 Shell access ok. |
Summary
Migrates ESLint from v7 +
.eslintrc.jsto v9 + flat config, adopting the@metamask/eslint-config*v15 family from the module template. Closes the four open Dependabot PRs that couldn't merge while we were still on v7 (#130, #131, #132, #133).Tooling changes
eslint:^7.24.0→^9.11.0@metamask/eslint-config*:^7→^15prettier:^2.2.1→^3.3.3(peer dep)@typescript-eslint/eslint-plugin+@typescript-eslint/parser— replaced by thetypescript-eslintmetapackage.eslint-plugin-import,eslint-plugin-node— replaced byeslint-plugin-import-xandeslint-plugin-n.eslint-plugin-jsdoc,eslint-plugin-promise,eslint-import-resolver-typescript(peer deps of the v15 configs).tsconfig split
ESLint v9 with type-aware rules needs all
.tsfiles (including tests) in some tsconfig. Sincetschere still emitslib/fornccto bundle, we can't use the template'snoEmit: truedirectly. Instead:tsconfig.json:noEmit: true, includes everything, used by ESLint and the IDE.tsconfig.build.json: extendstsconfig.json, adds emit settings, excludes tests. Used byyarn build:tsc.engines.nodebumpBumps
engines.nodefrom>=14.0.0to^20 || ^22 || >=24(template's range). This is enforced byeslint-plugin-n, which flaggednode:prefix imports as unsupported under the old range. It's also already true in practice: Yarn 4 + Corepack require Node ≥ 16, and.nvmrcis alreadylts/*. The Action runs on the consumer's Node, set via theirsetup-nodestep, so this field is informational.Source fixes
'fs'/'path'/'assert'/'process'imports to thenode:prefix._binding incatch (_)(ESLint v9 allows binding-lesscatch).interface→typewhere module-augmentation didn't forceinterface.import('.')inindex.test.tswith an inline disable (the test relies on side-effects firing on the next tick).Rules deliberately turned off
jsdoc/require-*— this repo doesn't JSDoc internals.import-x/no-nodejs-modules— this is a Node Action, so Node builtins are the norm.@typescript-eslint/explicit-function-return-type— the codebase relies on inference.@typescript-eslint/naming-convention— allowUPPER_CASEfor type members so env-var-shaped types match the actual env var names.dist/index.jsRegenerates with minor structural changes after the lockfile churn (different
nccchunking). Source behaviour is unchanged.Part of an opportunistic module-template sync.