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

Remove outdated babel reasonCode #15929

Merged
merged 3 commits into from
Jan 16, 2024
Merged
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
14 changes: 6 additions & 8 deletions src/language-js/parse/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function isFlowFile(text, options) {
function parseWithOptions(parse, text, options) {
const ast = parse(text, options);
const error = ast.errors.find(
(error) => !allowedMessageCodes.has(error.reasonCode),
(error) => !allowedReasonCodes.has(error.reasonCode),
);
if (error) {
throw error;
Expand Down Expand Up @@ -171,11 +171,11 @@ function createParse({ isExpression = false, optionsCombinations }) {
}

// Error codes are defined in
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/parser/error-message.js
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/plugins/typescript/index.js#L69-L153
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/plugins/flow/index.js#L51-L140
// - https://github.com/babel/babel/blob/v7.14.0/packages/babel-parser/src/plugins/jsx/index.js#L23-L39
const allowedMessageCodes = new Set([
// - https://github.com/babel/babel/tree/v7.23.6/packages/babel-parser/src/parse-error
// - https://github.com/babel/babel/blob/v7.23.6/packages/babel-parser/src/plugins/typescript/index.ts#L73-L223
// - https://github.com/babel/babel/blob/v7.23.6/packages/babel-parser/src/plugins/flow/index.ts#L47-L224
// - https://github.com/babel/babel/blob/v7.23.6/packages/babel-parser/src/plugins/jsx/index.ts#L23-L44
const allowedReasonCodes = new Set([
"StrictNumericEscape",
"StrictWith",
"StrictOctalLiteral",
Expand All @@ -190,8 +190,6 @@ const allowedMessageCodes = new Set([

"UnsupportedParameterPropertyKind",

"MixedLabeledAndUnlabeledElements",

"DuplicateAccessibilityModifier",

"DecoratorExportClass",
Expand Down