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

top level await #119

Open
1 task
grind-t opened this issue Dec 7, 2021 · 2 comments
Open
1 task

top level await #119

grind-t opened this issue Dec 7, 2021 · 2 comments

Comments

@grind-t
Copy link

grind-t commented Dec 7, 2021

Your Environment

  • Prettier version: 2.5.1
  • node version [16.13.0]:
  • package manager: [npm@8]
  • IDE: [VScode]

Describe the bug

Top level await is considered a syntax error.

To Reproduce

  1. Create index.mjs with the following code:
await Promise.resolve();
console.log("hello");
  1. Install prettier and try to format file (everything should work).
  2. Install @trivago/prettier-plugin-sort-imports and try to format file (A syntax error message should appear).

Expected behavior

There should be no syntax error.

Screenshots, code sample, etc

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

Error log

[error] index.mjs: SyntaxError: 'await' is only allowed within async functions. (1:0)
[error]   1 | await Promise.resolve();
[error]   2 | console.log("hello");
[error]   3 |

Contribute to @trivago/prettier-plugin-sort-imports

  • I'm willing to fix this bug 🥇
@rvion
Copy link

rvion commented Feb 22, 2022

This issue is preventing us from adopting the tool

@KilianB
Copy link

KilianB commented Mar 30, 2022

This is caused by the locked babel parser version #141 #147

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

No branches or pull requests

3 participants