chore: bump ESLint stack to v15 and migrate to flat config - #317
chore: bump ESLint stack to v15 and migrate to flat config#317cryptodev-2s wants to merge 2 commits into
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 6551ea9. Configure here.
6551ea9 to
311128a
Compare
311128a to
4adc549
Compare
16d390f to
9eb1d3a
Compare
Replaces .eslintrc.js with eslint.config.mjs and moves the whole ESLint
stack to the versions core uses.
eslint ^8.44.0 -> ^9.39.1
@metamask/eslint-config* ^12.0.0 -> ^15.0.0
@metamask/auto-changelog ^3.1.0 -> ^6.1.0
eslint-plugin-jest ^27.2.2 -> ^28.8.3
eslint-plugin-jsdoc ^39.9.1 -> ^50.2.4
eslint-plugin-n ^15.7.0 -> ^17.10.3
eslint-plugin-promise ^6.1.1 -> ^7.1.0
eslint-plugin-import removed, replaced by import-x
@typescript-eslint/{parser,plugin} removed, replaced by typescript-eslint
Added: typescript-eslint ^8.48.0, eslint-plugin-import-x ^4.3.0,
eslint-import-resolver-typescript ^3.6.3, @types/eslint ^9.6.1.
The flat config carries over the prettier/prettier and import-x/order
disables set in .eslintrc.js by the previous commit, since Oxfmt owns
formatting.
Also adds @types/semver ^7. It was previously reaching us transitively via
@typescript-eslint/eslint-plugin, so dropping that package broke the build
until it was declared directly.
Config v15 surfaced problems v12 never enforced. Most are stylistic and are
turned off with TODO comments, matching core. The rest were stale
eslint-disable directives pointing at rules typescript-eslint v8 renamed or
removed:
@typescript-eslint/no-throw-literal -> only-throw-error (8 sites)
@typescript-eslint/ban-types -> now unnecessary (3 sites)
jest/no-if -> removed in v28 (1 site)
Two autofixes were reverted because they changed behaviour rather than style:
hasProperty's constraint was rewritten from `Object` to `object`. The
original carried an explicit suppression, so it was deliberate: `Object`
accepts boxed primitives, and narrowing it would break callers passing a
string or number.
In json.test-d.ts the fixer stripped `as any` and `as number | undefined`
from tsd assertions. Those assertions are the test. no-unnecessary-type-
assertion is now off for *.test-d.ts so it cannot happen again.
jsdoc/require-jsdoc stays off for the same reason core keeps it off: its
autofixer inserts empty JSDoc blocks and mangles the surrounding code.
Verified: eslint, build, 23 suites / 1993 tests at 100% coverage, tsd, and
the full yarn lint all pass.
It was copied from smart-transactions-controller#595 without checking whether this package needs it. It does not: nothing here imports eslint types, eslint.config.mjs carries no annotations, and it is only an optional peer of eslint-plugin-prettier. Core does not have it at its root either. Removing it changes nothing: eslint, build, tests and lint all still pass.
0418ea3 to
cb576bc
Compare

Stacked on #314.
Replaces
.eslintrc.jswith a flateslint.config.mjsand moves the ESLint stack to core's versions.eslint^8.44.0^9.39.1@metamask/eslint-config{,-jest,-nodejs,-typescript}^12.0.0^15.0.0@metamask/auto-changelog^3.1.0^6.1.0eslint-plugin-jest^27.2.2^28.8.3eslint-plugin-jsdoc^39.9.1^50.2.4eslint-plugin-n^15.7.0^17.10.3eslint-plugin-promise^6.1.1^7.1.0Drops
eslint-plugin-importand@typescript-eslint/{parser,eslint-plugin}foreslint-plugin-import-xandtypescript-eslint. Adds@types/semver@^7, which had been arriving transitively through@typescript-eslint/eslint-pluginand broke the build once that was removed.Config v15 surfaced 351 problems v12 never enforced. Stylistic ones are off with TODO comments, matching core. The rest were stale directives naming rules that typescript-eslint v8 renamed or removed, so the code under them was going unchecked:
@typescript-eslint/no-throw-literalonly-throw-error@typescript-eslint/ban-typesimport/no-nodejs-modulesimport-x/no-nodejs-modulesjest/no-ifTwo autofixes are reverted because they changed behaviour rather than style:
hasProperty's constraint was rewritten fromObjecttoobject. The original carried an explicit suppression, soObjectwas deliberate: it accepts boxed primitives, and narrowing it breaks callers passing a string or number.json.test-d.tslostas anyandas number | undefinedfrom its tsd assertions. In type tests the assertion is the test.no-unnecessary-type-assertionis now off for*.test-d.ts.jsdoc/require-jsdocstays off rather than suppressed: its autofixer inserted 193 empty JSDoc blocks on the first pass. Core disables it for the same reason.Note
Low Risk
Tooling and lint-only source edits with no runtime API changes beyond type-only export syntax; main risk is CI/lint drift if config overrides hide real issues.
Overview
Migrates linting from
.eslintrc.jsto ESLint 9 flat config (eslint.config.mjs), bumps@metamask/eslint-configand related plugins to v15, and aligns dependencies with core (eslint-plugin-import-x,typescript-eslint, drops legacy@typescript-eslint/*packages).lint:eslintno longer passes--ext;@types/semveris added explicitly after the TS-eslint dependency chain went away.The new config turns off several JSDoc and TypeScript rules that v15 newly enforces (with TODOs), ignores
uuidforimport-x, disablesno-unnecessary-type-assertionin*.test-d.ts, and relaxes Node builtin checks in tests that polyfillcrypto.Across
src/, changes are mostly lint compliance: updated disable comments for renamed/removed rules,import-x/no-nodejs-modules,export type *for type-only modules, small typing/import cleanups, and preserving intentional behavior (e.g.hasPropertystill usesObject, tsd assertions kept intact).Reviewed by Cursor Bugbot for commit cb576bc. Bugbot is set up for automated code reviews on this repo. Configure here.