quick-lint-js icon indicating copy to clipboard operation
quick-lint-js copied to clipboard

Use of undeclared variable `await`

Open coderaiser opened this issue 1 year ago • 2 comments

Just trapped on couple issues:

image

Acorn:

image

ESPree:

image

No error: image

In chrome:

image

Babel:

image

coderaiser avatar Apr 28 '24 19:04 coderaiser

() => await; is legal in script mode. https://astexplorer.net/#/gist/ce7f1c8465166e5dd8923f21a71e6c5a/ca4992a4e78c2dfe0dbda6ade70d4700e7ce7efc quick-lint-js currently permits code which is legal in either script or module mode. It would be nice to have a better diagnostic like "missing expression after await and missing 'async' on function" though.

The story is similar for const await = 5; which is also legal in script mode. https://astexplorer.net/#/gist/ce7f1c8465166e5dd8923f21a71e6c5a/f4af94e61dfc6f2dd6bd6366074563db10196b73

What do you think quick-lint-js should do for these two examples?

strager avatar Apr 29 '24 01:04 strager

I think would be great to handle them as an error by default as other parsers and runtimes since no one will write such code nowadays or provide an option to switch between script and module.

coderaiser avatar Apr 29 '24 05:04 coderaiser