There is a way to use async top level with prettier ?
I'm actually trying to ignore my await top level with /prettier ignore
but prettier, ignore this line ...
CodePudding user response:
You can get Prettier to ignore line(s) with the following comment.
// prettier-ignore
const res = await asyncFunc();
This will make Prettier ignore the following line.
If you, however, want to make Prettier ignore multiple lines, then you can do something like this:
// prettier-ignore
{
const res = await asyncFunc();
const data = await getData();
}
This will make Prettier not format the code surrounded by { }
. The comments and brackets/parentheses might help you with making Prettier ignore top-level await
.
Right now, there is no option for enabling top-level await
in Prettier. However, there is an unsolved GitHub Issue here.