Skip to content

Commit

Permalink
fix: range matching fails
Browse files Browse the repository at this point in the history
fixes #22
  • Loading branch information
aladdin-add committed Jun 16, 2022
1 parent 793a48b commit 4b4b169
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/rules/no-unsupported-features/es-syntax.js
Expand Up @@ -7,6 +7,7 @@
const { rules: esRules } = require("eslint-plugin-es")
const { getInnermostScope } = require("eslint-utils")
const { Range } = require("semver")
const rangeSubset = require("semver/ranges/subset")
const getConfiguredNodeVersion = require("../../util/get-configured-node-version")
const getSemverRange = require("../../util/get-semver-range")
const mergeVisitorsInPlace = require("../../util/merge-visitors-in-place")
Expand Down Expand Up @@ -457,11 +458,11 @@ function defineVisitor(context, options) {
return true
}

if (aCase.supported instanceof Range) {
return !options.version.intersects(aCase.supported)
}

return options.version.intersects(getSemverRange(`<${aCase.supported}`))
const supported =
typeof aCase.supported === "string"
? getSemverRange(`>=${aCase.supported}`)
: aCase.supported

This comment has been minimized.

Copy link
@aladdin-add

aladdin-add Jun 16, 2022

Author

atm, the supported must be a version("x.y.z"), good to support something like "^12.2 || >=13".

return !rangeSubset(options.version, supported)
}

/**
Expand Down

0 comments on commit 4b4b169

Please sign in to comment.