Skip to content

Respect minor Node versions when picking the ES feature set#156

Merged
alexander-akait merged 3 commits into
mainfrom
claude/fix-node-version-detection-jp2Xi
May 15, 2026
Merged

Respect minor Node versions when picking the ES feature set#156
alexander-akait merged 3 commits into
mainfrom
claude/fix-node-version-detection-jp2Xi

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Move the node-to-ES mapping into a dedicated util that matches semver
ranges instead of switching on the major version, so node engine ranges
whose ES level changes mid-major get the right level:

  • =7.6 now maps to ES2017 (async/await), not ES2016.

  • =16.11 now maps to ES2022 (Object.hasOwn); earlier 16.x stays on
    ES2021 since Object.hasOwn isn't there yet.

Node 6 and the Node 12/13 globals tweak remain handled inline in
configs.js — they don't map cleanly to a single ES year.

https://claude.ai/code/session_01PWS1MsGoEEm8MPYqU7fx3f

claude added 3 commits May 14, 2026 14:25
Move the node-to-ES mapping into a dedicated util that matches semver
ranges instead of switching on the major version, so node engine ranges
whose ES level changes mid-major get the right level:

  - >=7.6 now maps to ES2017 (async/await), not ES2016.
  - >=16.11 now maps to ES2022 (Object.hasOwn); earlier 16.x stays on
    ES2021 since Object.hasOwn isn't there yet.

Node 6 and the Node 12/13 globals tweak remain handled inline in
configs.js — they don't map cleanly to a single ES year.

https://claude.ai/code/session_01PWS1MsGoEEm8MPYqU7fx3f
…ixture

* `configs/utils/get-es-version-from-node.test.js` — node:test suite
  covering major boundaries, the minor-version boundaries we now respect
  (Node 7.6 → ES2017, Node 16.11 → ES2022), non-`>=` range shapes
  (^, ~, exact, OR), and graceful fallback for ranges below Node 7,
  Node 6, and unparseable input.

* The util now wraps `semver.minVersion` in try/catch so a malformed
  `engines.node` produces `undefined` (fall back to recommended)
  instead of crashing the ESLint config load.

* `npm test` (added) runs the suite via Node's built-in test runner —
  no extra deps, executes natively on Node 20.9+.

* `validation/module-package/import-attributes.js` — exercises
  `import x from "./y.json" with { type: "json" }`. Bumped the
  >=22 row in the util to ES2025 so Node 22+ projects get
  ecmaVersion 2025 and the parser accepts import attributes; ES2024
  stdlib gaps are still caught by eslint-plugin-n at runtime.
  An eslint.config.js override pins the fixture to ecmaVersion 2025
  so we can lint it within this repo (whose own engines.node pin is
  20.9). The fixture also executes cleanly on Node 22.

https://claude.ai/code/session_01PWS1MsGoEEm8MPYqU7fx3f
Per review: this repo expresses coverage via the eslint-as-tests
fixtures under validation/, not a separate test runner. Remove the
node:test suite and the `npm test` script — the import-attributes
fixture in validation/module-package/ still exercises the
Node 22 → ES2025 mapping end-to-end via eslint + node.

The defensive `try/catch` around `semver.minVersion` in
get-es-version-from-node.js stays (malformed `engines.node`
should fall back, not crash).

https://claude.ai/code/session_01PWS1MsGoEEm8MPYqU7fx3f
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@changeset-bot

changeset-bot Bot commented May 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eb71850

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-config-webpack Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alexander-akait alexander-akait merged commit 0987fa1 into main May 15, 2026
9 of 10 checks passed
@alexander-akait alexander-akait deleted the claude/fix-node-version-detection-jp2Xi branch May 15, 2026 14:13
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.

2 participants