Skip to content

Commit

Permalink
Remove outdated babel reasonCode (prettier#15929)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and medikoo committed Feb 17, 2024
1 parent a7a6775 commit df793eb
Showing 1 changed file with 6 additions and 8 deletions.
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

0 comments on commit df793eb

Please sign in to comment.