-
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
addons-linter fails with errors when using dynamic import syntax #2940
Comments
The scriptType is currently detected from src/scanners/javascript.js here: addons-linter/src/scanners/javascript.js Lines 223 to 241 in 8ecba89
If What seems to be making This seems to also been reported upstream in the espree and eslint repos (but both these issues have been closed but the issue is stil there, from a quick look it seems that babel-eslint is the strategy used to workaround the issue at the moment): |
Except it wasn't just throwing errors on the // 1. vanilla `import .. from`
import {ConnectionTester} from "./connection.js"; // background/main.js:1
// 2. dynamic `import()`
const {View} = await import("./view.js"); // popup/popup.js:4
// 3. vanilla `export`
export class View { // popup/view.js:7 |
The line and column shown in the linter results is not what I'm referring to. As I mentioned in my previous comment the actual error raised by espree is not logged anywhere, after that error happens we fall back to parse the file as a "script" instead of a "module" and so the linter will mark the first Anyway, the espree errors that triggered the unexpected behavior are all referring to lines with a dynamic import:
To detect the line where the espree error is originally raised, I added the following temporary change locally: try {
const ast = espree.parse(this.code, parserOptions);
sourceType = this._getSourceType(ast);
} catch (exc) {
console.log("DEBUG error detecting sourceType", filename, exc);
sourceType = 'script';
} And, by running it on the secure-proxy sources, I got the following logs for the error that prevented the file to be linted as a "module":
|
Firefox addons linter does not currently support See: mozilla/addons-linter#2940 Since migrations are currently limited and this was simply a refactoring, easier to revert and reconsider introducing later, than to fight with Firefox linter. Reverts b27e135
This issue has been automatically marked as stale because it has not had recent activity. If you think this bug should stay open, please comment on the issue with further details. Thank you for your contributions. |
duplicate of #2498 |
Describe the problem and steps to reproduce it:
I'm trying to run npx addons-linter --self-hosted ./src on https://github.com/mozilla/secure-proxy/ and am getting a few errors.
This is my current output:
What happened?
Where the errors in question are from:
background/main.js:1
popup/popup.js:4
popup/view.js:7
What did you expect to happen?
No errors on
import
/export
.Anything else we should know?
You're awesome.
npx addons-linter --version # 1.14.0
The text was updated successfully, but these errors were encountered: