Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

67
Visualizações
Prettier with top level async

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 ...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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.


EDIT: The easiest option, though, is to just use an async function (until Prettier supports it).

(async (param) => {
  await getData(param);
})()

The anonymous async function above will call itself straight away, so it'll act like await has no async function.

With this method, Prettier will be happy. 🙂

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda