prettier-plugin-sort-imports icon indicating copy to clipboard operation
prettier-plugin-sort-imports copied to clipboard

top level await

Open grind-t opened this issue 2 years ago • 2 comments

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 🥇

grind-t avatar Dec 07 '21 23:12 grind-t

This issue is preventing us from adopting the tool

rvion avatar Feb 22 '22 15:02 rvion

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

KilianB avatar Mar 30 '22 12:03 KilianB