Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: no-unsupported-features/es-builtins: fetch reported unsupported despite Node.js >=18.16.0 #253

Closed
1 task
caugner opened this issue Apr 24, 2024 · 7 comments
Labels

Comments

@caugner
Copy link

caugner commented Apr 24, 2024

Environment

Node version: 18.20.1
npm version: 10.5.0
ESLint version: 8.57.0
eslint-plugin-n version: 17.3.0
Operating System: Mac OS / Ubuntu 22.04

What rule do you want to report?

n/no-unsupported-features/es-builtins

Link to Minimal Reproducible Example

(unclear how to reproduce this on the ESLint playground)

What did you expect to happen?

I expected the following to not cause any errors:

git clone -b dependabot/npm_and_yarn/eslint-plugin-n-17.3.0 [email protected]:mdn/yari.git --depth=1
cd yari
yarn install
yarn eslint .

But actually I'm seeing these errors, although our package.json requires Node.js >=18.16.0:

  30:31  error  The 'fetch' is still an experimental feature and is not supported until Node.js 18.0.0. The configured version range is '>=18.0.0'  n/no-unsupported-features/es-builtins
  36:34  error  The 'fetch' is still an experimental feature and is not supported until Node.js 18.0.0. The configured version range is '>=18.0.0'  n/no-unsupported-features/es-builtins

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Noticed via failing test in this Dependabot PR.

@caugner caugner added the bug label Apr 24, 2024
@scagood
Copy link

scagood commented Apr 24, 2024

Thank you for the report!

🤔 Technically fetch was not supported until 21.0.0, and so should be experimental in 18.20.1:
image


However, there is still a bug here, as we mark is as supported in v18:

fetch: {
[READ]: { supported: ["18.0.0"] },
},

This could be related to #252, but 18.0.0 is a subset of >=18.0.0.

@scagood
Copy link

scagood commented Apr 24, 2024

It makes me think that the wrong value is getting to isSupported

As the range is truthy:
https://runkit.com/scagood/662900db83c1e60008f2ccd4

image

@aladdin-add
Copy link

> semverRangeSubset('>=18.1.0', '>=18.0.0 <19||>18')
false

it seems an issue in node-semver. I'll revert that change then.

@aladdin-add
Copy link

@scagood
Copy link

scagood commented Apr 24, 2024

mmm, that is a strange bug!

const subset = require("semver/ranges/subset")

subset('^17.2.0 || >17', '^17.2.0 || >17')  // true
subset('^17.2.0 || >17', '^17.2.0 || >=18') // true
subset('^17.2.0 || >=18', '^17.2.0 || >17') // true

subset('^17.2.0 || >17', '>=17.2.0') // true
subset('>=17.2.0', '^17.2.0 || >17') // false

subset('^17.2.0 || >=18', '>=17.2.0') // true
subset('>=17.2.0', '^17.2.0 || >=18') // false

I was wondering if something like this would work, but alas it does not either:

const [ latest ] = rsort(supported);
const range = getSemverRange(
  [
    ...supported.map((version) => `^${version}`),
    `>= ${major(latest + 1)}`,
  ].join('||'),
);

@aladdin-add
Copy link

can you file the issue in node-semver repo, please? 🙏

@scagood
Copy link

scagood commented Apr 28, 2024

I am going to close this, as I think the patch did fix it.

We can track the semver issue in #250.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants