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

update: hardcode @babel/eslint-parser min supported version check #11896

Merged
merged 4 commits into from Jul 30, 2020
Merged
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions eslint/babel-eslint-parser/src/index.js
Expand Up @@ -12,19 +12,22 @@ import convert from "./convert";
import analyzeScope from "./analyze-scope";
import visitorKeys from "./visitor-keys";

let isRunningSupportedVersion;
let isRunningMinSupportedCoreVersion = null;

function baseParse(code, options) {
if (typeof isRunningSupportedVersion !== "boolean") {
isRunningSupportedVersion = semver.satisfies(
const minSupportedCoreVersion = ">=7.0.0";
Copy link
Member

@hzoo hzoo Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so parse was added first in 7.0? (either way 7 seems good)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whoops, I was looking at this. Actual PR is here. Will update!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@babel/core#parse() was added in 7.0.0-beta.51, but we need to bump this to 7.2.0 so that we have access to @babel/parser#tokTypes.


if (typeof isRunningMinSupportedCoreVersion !== "boolean") {
isRunningMinSupportedCoreVersion = semver.satisfies(
babelCoreVersion,
packageJson.peerDependencies["@babel/core"],
minSupportedCoreVersion,
);
}

if (!isRunningSupportedVersion) {
// Ensure we're using a version of `@babel/core` that includes the `parse()` API.
if (!isRunningMinSupportedCoreVersion) {
throw new Error(
`@babel/eslint-parser@${packageJson.version} does not support @babel/core@${babelCoreVersion}. Please upgrade to @babel/core@${packageJson.peerDependencies["@babel/core"]}`,
`@babel/eslint-parser@${packageJson.version} does not support @babel/core@${babelCoreVersion}. Please upgrade to @babel/core@${minSupportedCoreVersion}`,
);
}

Expand Down