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

Use of undeclared variable await #1220

Open
coderaiser opened this issue Apr 28, 2024 · 2 comments
Open

Use of undeclared variable await #1220

coderaiser opened this issue Apr 28, 2024 · 2 comments

Comments

@coderaiser
Copy link

Just trapped on couple issues:

image

Acorn:

image

ESPree:

image

No error:
image

In chrome:

image

Babel:

image
@strager
Copy link
Collaborator

strager commented Apr 29, 2024

() => 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?

@coderaiser
Copy link
Author

coderaiser commented Apr 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants