-
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
Linter objects to use of import.meta
while extension works just fine
#4331
Comments
That's because we are unable to detect ESM but I am not too sure. Did you try to use a |
I did indeed. Here is the exact change I tested. The lint output of
|
It looks like your bundler still outputs |
Good point. web-ext lint can't know what happens before bundling, and Parcel isn't aware that the I'll ask the Parcel team if preserving the extension would be an option for them. If not, is there any other way I can indicate to web-ext lint that it's a module file? |
There has been work to do this in the past but I am not sure that led anywhere (#4020). We know this is a (annoying) limitation, though. |
I had a couple of ideas but none of them seem actionable yet. They were:
Anyway, thank you for helping me understand what's going on. I'll check if there's anything that can be done from Parcel's end. |
Good news, it's solvable from Parcel's end. There's no need to adapt the linter for my case. |
I think this issue should still be solved here. If the extension works in the browser, then the bug is web-ext’s |
My extension was actually removed from addons.mozilla.org yesterday because of this issue. My workaround since this first happened in April has been to manually rename files to .mjs after build, and that worked until a manual review, when I got a notice that the build no longer matched the submitted extension. I explained the situation, but that didn't help, and the extension was removed. I tried the workaround mentioned by @pieterdd, but it didn't work for me. I get an error at build that I haven't been able to solve yet. I concur with @fregante. I have a fully functional addon, and I don't think I should have to change my addon to work around a linter issue. And now my addon is unavailable because of it. |
I'll reopen it if you feel strongly about it, but I (being the person who originally started the thread) can live with the workaround so I'll unsubscribe from the thread. |
We'll accept a patch that falls back to re-interpreting the file as a module script when the error clearly indicates that the script fails due to the use of |
Awesome! I just submitted a patch for review! |
@willdurand Sorry not noticing this issue earlier, could you add some str for qa in case I can check on this? |
@willdurand You don't have to, I took an example of import.meta from here Before the fix, on linter 5.9.0 I got the error described above Right now with 5.13.0 same testing sample passed validation I attached the zip file I've tested with. |
Ha, excellent! Thank you for verifying the issue. |
Describe the problem and steps to reproduce it:
rm -rf dist && yarn build && yarn web-ext lint -s build
The following error appears:
The extension itself seems to work fine, but the linter still objects to it.
What happened?
I got a lint error.
What did you expect to happen?
Given that the extension seems to work fine, I expected not to get a lint error.
Anything else we should know?
Since I use Parcel as my bundler, I brought it up with the Parcel team before coming here. A member concluded:
I also noticed that
import.meta
was added to the language specification. Among modern browsers, all the major ones seem to support it as of 2020 without caveats.I took note of #3639 but didn't find a solution there.
The text was updated successfully, but these errors were encountered: