Respect minor Node versions when picking the ES feature set#156
Merged
Conversation
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
|
🦋 Changeset detectedLatest commit: eb71850 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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