-
Notifications
You must be signed in to change notification settings - Fork 144
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
Detect import.meta as module in .js files #4399
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4399 +/- ##
=======================================
Coverage 98.71% 98.71%
=======================================
Files 54 54
Lines 2811 2812 +1
Branches 840 840
=======================================
+ Hits 2775 2776 +1
Misses 36 36
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, sorry for the delay. That looks promising, thanks!
The requested changes have been made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the patch. Could you please re-add the test case you had initially? We still need to cover the change for import.meta
.
The unit test has been re-added. |
Fixes #4331 and #3639
When using import.meta in a .js file, the linter returns an error, "Cannot use 'import.meta' outside a module", unless the source type is detected as a module by the use of an import/export. This patch parses the code as a script if a .js file contains import.meta and it hasn't already been detected as a module by the use of an import/export. If the specific import.meta error is found during the catch block, then the source type is set as a module.
This patch does result in the code being parsed again, but that happens only in the specific situation that currently causes an error. Considering that the use of import.meta within a .js file is currently preventing addons from being able to pass the linter, I believe this is an acceptable workaround.
A unit test has also been added to test the patch.