Linter can't parse module with class fields, workaround?

Hello,

I made my first extension which is working fine in debug mode on Firefox 92.0, but I can’t pass the linter or even add my extension manually to Firefox (message about it being corrupted).
Looks like the linter does not like class fields. I think this is a known issue as this github issue suggests (although I don’t understand everything).

While I wait until this is fixed, I have two questions:

  • Is there anything I can do to pass the linter yet? Without having to remove all import/export and classes, it would be nice.
  • Is there any way I can use my extension without debug mode? I don’t even want to publish it yet, just use it for myself but firefox keeps telling me it’s corrupted and refuses to install it manually. It’s not really corrupted as it works fine in debug mode without any error…

Here is the linter message if needed:

JavaScript syntax error (Parsing as module error: Unexpected token ; at line: 15 and column: 17) (Parsing as script error: ‘import’ and ‘export’ may appear only with ‘sourceType: module’ at line: 1 and column: 1)

Error: There is a JavaScript syntax error in your code, which might be related to some experimental JavaScript features that aren’t an official part of the language specification and therefore not supported yet. The validation cannot continue on this file.

At line 1 I export a const object and at line 15 I have my first declared class property.

Thanks!

ES Modules should be fine for normal extension scripts (that excludes content scripts), make sure they are loaded as <script type="module"> in HTML.

The “work around” for class fields is to just initialize them in the constructor for now.

The alternative to using about:debugging to avoid signing is to use an unbranded build.

1 Like

Wow that was easy, thanks a lot, initialization in constructor worked fine!