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 babel parser #10802

Merged
merged 12 commits into from May 3, 2021
Merged

Conversation

sosukesuzuki
Copy link
Member

Description

Error Codes are introduced in babel/parser since Babel 7.14.0. Also almost error messages throw by babel/parser are fixed for consistent.

Checklist

Try the playground for this PR

"Unexpected token (4:10)
2 | static #x = 42;
3 | static y;
> 4 | static {
Copy link
Member Author

Choose a reason for hiding this comment

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

This should be fixed by babel/parser.

Copy link
Member Author

Choose a reason for hiding this comment

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


return true;
function shouldRethrowRecoveredError(error) {
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Remove this function, use allowedMessageCodes directly.

"throwExpressions",
"classPrivateMethods",
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Can moduleStringNames plugin removed?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

// - 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([
"StrictNumericEscape",
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

The error codes seem less readable than the message. 😢

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably these error codes are used by only us now, so we can fix too less readable messages on Babel side.

Comment on lines -13 to -24
'interface = "foo";',
"interface + 3;",
"interface();",
"class interface {}",
"interface ? true : false;",
"function interface() {}",
'import interface from "foo";',
"interface.foo;",
"new interface();",
'(interface, "foo");',
"void interface;",
'const interface = "foo";',
Copy link
Member Author

Choose a reason for hiding this comment

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

This change makes the Reserved word check rough...

@sosukesuzuki sosukesuzuki requested review from fisker and thorn0 May 1, 2021 05:13
@sosukesuzuki sosukesuzuki merged commit 63c7448 into prettier:main May 3, 2021
@sosukesuzuki sosukesuzuki deleted the update-babel-parser branch May 3, 2021 03:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants