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

Whitelist recovered babel parse errors #10495

Merged
merged 2 commits into from
Mar 13, 2021
Merged

Conversation

fisker
Copy link
Member

@fisker fisker commented Mar 9, 2021

Description

Some listed errors still should throw, but we can fix them later.
I believe this may also break some valid case, for example legacy things in non-strict mode, maybe we can try parse as non-strict if find it's necessary.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

Copy link
Member

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

I think it is annoying to have to update this every time a new error message is added to Babel. What is the purpose of this change?

@thorn0
Copy link
Member

thorn0 commented Mar 10, 2021

@sosukesuzuki We discussed this in #9979. The idea is to allow only specific errors and rethrow anything else. I didn't expect the list to be so long, but it seems to make sense.

it is annoying to have to update this every time a new error message is added to Babel

It's vice versa. Now we have to monitor when Babel adds new recoverable errors and either add support for them or rethrow them, i.e. update the current blocklist. After this change, the new list will be updated only when we deliberately decide to support some specific case of error recovery.

@fisker
Copy link
Member Author

fisker commented Mar 11, 2021

I will also try clean this list later, I want keep this PR small.

@sosukesuzuki
Copy link
Member

I got it! It makes sense.

Btw, I don't like Babel error messages are hard coded. It may be good to introduce error code for recoverable errors at Babel side. What do you think?

@fisker
Copy link
Member Author

fisker commented Mar 11, 2021

Yes, that would be great, but I guess it's not doable... because some messages are from babel plugin.

@sosukesuzuki
Copy link
Member

The Babel parser plugin isn't external code, so it may be possible. I'll look into it.

@thorn0 thorn0 merged commit 3995c2a into prettier:main Mar 13, 2021
@fisker fisker deleted the whitelist-errors branch March 14, 2021 00:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 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

3 participants