quick-lint-js
quick-lint-js copied to clipboard
Use of undeclared variable `await`
Just trapped on couple issues:
Acorn:
ESPree:
No error:
In chrome:
Babel:
() => 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?
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.