Skip to content
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

JavaScript syntax error with numeric separator #3543

Closed
michaelts1 opened this issue Jan 13, 2021 · 5 comments · Fixed by #3544
Closed

JavaScript syntax error with numeric separator #3543

michaelts1 opened this issue Jan 13, 2021 · 5 comments · Fixed by #3544
Assignees
Labels
priority:p3 type:syntax Issues related to JavaScript syntax (support).

Comments

@michaelts1
Copy link
Contributor

michaelts1 commented Jan 13, 2021

What happened?

I ran Add-ons Linter from the command line, and got a validation error:

There is a JavaScript syntax error in your code; validation cannot continue on this file.

Which points to this line of code, at column 14:
let tmp = 10_000.
It seems that the error is caused by the numeric separator.

What did you expect to happen?

I expect that Add-ons Linter will not throw any errors, since the use of numeric separators is described on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Numeric_separators, and is supported since Firefox 70, which was released more than a year ago.

@Rob--W
Copy link
Member

Rob--W commented Jan 13, 2021

Which version of addons-linter are you using?

We rely on eslint for parsing the file, and eslint already supports it since v7.8.0 (https://github.com/eslint/eslint/releases/tag/v7.8.0).

We are currently using eslint 7.17.0 -

"eslint": "7.17.0",

@michaelts1
Copy link
Contributor Author

Running addons-linter --version gives me "2.16.0".
Running eslint --version, gives me "v7.17.0".

I created a folder containing only one file that contains only the following line: 1_0;.
Running addons-linter ./ still gives me the same error:

There is a JavaScript syntax error in your code; validation cannot continue on this file.
test.js 1 3

@Rob--W
Copy link
Member

Rob--W commented Jan 13, 2021

I see the reason... We're specifying ecmaVersion: 2020 but numeric literals require 2021 per eslint/js#448

To fix this, we need to change 2020 to 2021 at

const ECMA_VERSION = 2020;

and add a unit test (to verify that we support numeric separators) in https://github.com/mozilla/addons-linter/blob/be94690d29118a0f3c642b2803148a2699b69d67/tests/unit/scanners/test.javascript.js

Are you interested in contributing a patch?

@michaelts1
Copy link
Contributor Author

I created a pull request to fix this issue.

@willdurand willdurand added type:syntax Issues related to JavaScript syntax (support). priority:p3 labels Jan 15, 2021
@willdurand
Copy link
Member

thanks @michaelts1!

This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p3 type:syntax Issues related to JavaScript syntax (support).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants