addons-linter: Syntax error with a top-level await and no import

Describe the problem and steps to reproduce it:

Files with a top-level await and no import: returns a syntax error.

await browser.storage.local.get();

What happened?

Validation Summary:

errors          1              
notices         0              
warnings        0              

ERRORS:

Code              Message        Description               File          Line   Column
JS_SYNTAX_ERROR   JavaScript     There is a JavaScript     testcase.js   1      7     
                  syntax error   syntax error in your                                
                   (Parsing as   code, which might be                                
                  script         related to some                                     
                  error:         experimental JavaScript                             
                  Unexpected     features that aren't an                             
                  token          official part of the                                
                  browser at     language specification                              
                  line: 1 and    and therefore not                                   
                  column: 7)     supported yet. The                                  
                                 validation cannot                                   
                                 continue on this file.

What did you expect to happen?

No error reported.

Anything else we should know?

I have no error with ESLint.

┆Issue is synchronized with this Jira Task

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@regseb

I tried on linter 6.2.0 with const foo = await Promise.resolve(); -> got the error mentioned

Then with 6.3.0 -> addon passed validation without problems.

I tested with a background.mjs file containing an import. I loaded with a <script> without type attribut in the background.page and I have the error:

Uncaught SyntaxError: import declarations may only appear at top level of a module