Skip to content

fix(next-codemod): only bump eslint when it does not satisfy the eslint-config-next peer range - #98593

Open
devtechedge wants to merge 1 commit into
vercel:canaryfrom
devtechedge:fix/codemod-eslint-below-range
Open

fix(next-codemod): only bump eslint when it does not satisfy the eslint-config-next peer range#98593
devtechedge wants to merge 1 commit into
vercel:canaryfrom
devtechedge:fix/codemod-eslint-below-range

Conversation

@devtechedge

Copy link
Copy Markdown

What?

@next/codemod upgrade no longer rewrites the project's eslint specifier
when it already satisfies the eslint-config-next peer range. A project on
eslint@^9 stays on ^9 instead of being pinned to the newest ESLint 10
release.

When a bump is still required (for example eslint@^8 against a >=9 peer),
the tool pins the highest release of the lowest major satisfying the peer
range, so projects land on the closest satisfying major instead of the newest
eslint release.

Fixes #98417

Why?

eslint-config-next@16 declares eslint: ">=9.0.0". The upgrade tool called
loadHighestNPMVersionMatching("eslint@>=9") and wrote the result as an exact
pin, so a project on ^9 got forced onto the newest ESLint 10 release. With
plugins that do not support ESLint 10 yet (e.g. eslint-plugin-import), the
post-upgrade npm install failed before any transformation ran, per the
linked issue's repro.

How did you fix it?

  • New pure helper resolveEslintUpgradeTarget in bin/shared.ts. It returns
    null (leave the specifier untouched) when the installed specifier satisfies
    the peer range - including specifiers entirely above the peer minimum, so
    nothing gets downgraded - or when it cannot be interpreted as a semver range
    (latest, workspace/npm aliases). Otherwise it resolves the highest release
    of the lowest major satisfying the peer range through the injected resolver.
  • bin/upgrade.ts uses the helper for the eslint alignment step. Behavior for
    projects below the peer range is unchanged except that the target is the
    lowest satisfying major rather than the newest release.
  • Unit tests for the decision table in
    bin/__tests__/eslint-upgrade-target.test.ts.

How to test?

…nt-config-next peer range

The upgrade tool resolved the newest eslint release matching the
eslint-config-next peer range and pinned it, even when the project's
existing specifier already satisfied that range. Projects using plugins
that do not support the newest eslint major yet failed npm install
before any transformation ran.

Leave the specifier untouched when it satisfies the peer range. When a
bump is required, pin the highest release of the lowest major
satisfying the range instead of the newest eslint release.

Fixes vercel#98417
devtechedge added a commit to devtechedge/oss-contributions that referenced this pull request Sep 11, 2026
devtechedge added a commit to devtechedge/oss-contributions that referenced this pull request Sep 12, 2026
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.

@next/codemod upgrade pins ESLint to 10 unprompted, failing install for projects using eslint-plugin-import

1 participant