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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate to @babel/parser #355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pionxzh
Copy link
Contributor

@pionxzh pionxzh commented Jan 13, 2024

This PR replaces the existing parser from espree to @babel/parser.

There is only 1 failed test:

+ expected - actual

 class Foo {
-  bar() {
-    console.log(arguments);
+  bar(...args) {
+    console.log(args);
   }
 }

escope does not recognize ClassMethod from babel. I'm not sure how to fix it. This must be done on escope side.


I have verified that acorn and espree will trigger issue #352 , all other parsers are ok. But esprima is kind of dead. Typescript will run into the escope issue too. That's why I choose babel.

I started to want to patch recast by myself to fix the original issue. But maybe this PR is complete enough that you will have an interest in it. If you think this is not the direction to go, can close. 馃檹

'foo();\n' +
'"use strict";\n' +
'bar();'
'function foo() {\n' +
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only test I changed. According to the spec, the original "use strict" is just a string literal. So, I move it into the function body to make it a strict mode for function.

@nene
Copy link
Collaborator

nene commented Jan 13, 2024

Thanks for the PR.

See the comment in #352 issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants