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

fix: unsupported-features/node-builtins-modules #257

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/util/check-unsupported-builtins.js
Expand Up @@ -4,11 +4,12 @@
*/
"use strict"

const { major, rsort } = require("semver")
const { rsort } = require("semver")
const { ReferenceTracker } = require("@eslint-community/eslint-utils")
const getConfiguredNodeVersion = require("./get-configured-node-version")
const getSemverRange = require("./get-semver-range")
const unprefixNodeColon = require("./unprefix-node-colon")
const semverRangeSubset = require("semver/ranges/subset")

/**
* Parses the options.
Expand Down Expand Up @@ -38,19 +39,14 @@ function isSupported({ supported }, configured) {

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

if (range == null) {
return false
}

return configured.intersects(range)
return semverRangeSubset(configured, range)
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/rules/no-unsupported-features/es-builtins.js
Expand Up @@ -2424,6 +2424,23 @@ runTests([
},
],
},
// https://github.com/eslint-community/eslint-plugin-n/issues/250
scagood marked this conversation as resolved.
Show resolved Hide resolved
{
code: "function wrap() { globalThis }",
settings: {
node: { version: ">=11.9.9" },
},
errors: [
{
messageId: "not-supported-till",
data: {
name: "globalThis",
supported: "12.0.0",
version: ">=11.9.9",
},
},
],
},
],
},
])